mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into fix5953_crashJSX
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// @target: es5
|
||||
|
||||
// Repro from #6000
|
||||
|
||||
const a = {
|
||||
b: {
|
||||
get foo(): string {
|
||||
return a.foo;
|
||||
},
|
||||
set foo(value: string) {
|
||||
a.foo = value;
|
||||
}
|
||||
},
|
||||
foo: ''
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
// Repro from #6072
|
||||
|
||||
class Foo {}
|
||||
|
||||
function maker (value: string): typeof maker.Bar {
|
||||
return maker.Bar;
|
||||
}
|
||||
|
||||
namespace maker {
|
||||
export class Bar extends Foo {}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @declaration: true
|
||||
|
||||
// Repro from #6040
|
||||
|
||||
function append<a, b extends a>(result: a[], value: b): a[] {
|
||||
result.push(value);
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export * from "file1"
|
||||
var x;
|
||||
@@ -0,0 +1,12 @@
|
||||
// @module: system
|
||||
|
||||
// @filename: file0.ts
|
||||
export var v = 1;
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export * from "file0";
|
||||
export * from "file1";
|
||||
var x = 1;
|
||||
@@ -0,0 +1,12 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export * from "file1"
|
||||
var x = 1;
|
||||
|
||||
// @filename: file3.ts
|
||||
export * from "file2"
|
||||
var x = 1;
|
||||
@@ -0,0 +1,24 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export interface A { x }
|
||||
export * from "file1"
|
||||
var x = 1;
|
||||
|
||||
// @filename: file3.ts
|
||||
export interface B { x }
|
||||
export * from "file1"
|
||||
var x = 1;
|
||||
|
||||
// @filename: file4.ts
|
||||
export interface C { x }
|
||||
export * from "file2"
|
||||
export * from "file3"
|
||||
var x = 1;
|
||||
|
||||
// @filename: file5.ts
|
||||
export * from "file4"
|
||||
var x = 1;
|
||||
@@ -0,0 +1,15 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export interface A { x }
|
||||
export * from "file1"
|
||||
export * from "file3"
|
||||
var x = 1;
|
||||
|
||||
// @filename: file3.ts
|
||||
export interface B { x }
|
||||
export * from "file2"
|
||||
var x = 1;
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export * from "file1"
|
||||
export var x;
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module: system
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export * from "file1"
|
||||
export var x = 1;
|
||||
@@ -0,0 +1,12 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export * from "file1"
|
||||
export var x = 1;
|
||||
|
||||
// @filename: file3.ts
|
||||
export * from "file2"
|
||||
export var x = 1;
|
||||
@@ -0,0 +1,24 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export interface A { x }
|
||||
export * from "file1"
|
||||
export var x = 1;
|
||||
|
||||
// @filename: file3.ts
|
||||
export interface B { x }
|
||||
export * from "file1"
|
||||
export var x = 1;
|
||||
|
||||
// @filename: file4.ts
|
||||
export interface C { x }
|
||||
export * from "file2"
|
||||
export * from "file3"
|
||||
export var x = 1;
|
||||
|
||||
// @filename: file5.ts
|
||||
export * from "file4"
|
||||
export var x = 1;
|
||||
@@ -0,0 +1,15 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export interface A { x }
|
||||
export * from "file1"
|
||||
export * from "file3"
|
||||
export var x = 1;
|
||||
|
||||
// @filename: file3.ts
|
||||
export interface B { x }
|
||||
export * from "file2"
|
||||
export var x = 1;
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module: system
|
||||
|
||||
// @filename: file1.ts
|
||||
export interface Foo { x }
|
||||
|
||||
// @filename: file2.ts
|
||||
export * from "file1"
|
||||
var x = 1;
|
||||
@@ -0,0 +1,8 @@
|
||||
let data = {
|
||||
public foo: 'hey',
|
||||
private bar: 'nay',
|
||||
protected baz: 'oh my',
|
||||
abstract noWay: 'yes'
|
||||
};
|
||||
|
||||
data.foo + data.bar + data.baz + data.noWay
|
||||
@@ -0,0 +1,30 @@
|
||||
// @target: ES5
|
||||
|
||||
class MyBase {
|
||||
getValue(): number { return 1; }
|
||||
get value(): number { return 1; }
|
||||
}
|
||||
|
||||
class MyDerived extends MyBase {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
const f1 = super.getValue();
|
||||
const f2 = super.value;
|
||||
}
|
||||
}
|
||||
|
||||
var d = new MyDerived();
|
||||
var f3 = d.value;
|
||||
|
||||
class A {
|
||||
private _property: string;
|
||||
get property() { return this._property; }
|
||||
set property(value: string) { this._property = value }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
set property(value: string) {
|
||||
super.property = value + " addition";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// @target: ES6
|
||||
|
||||
class MyBase {
|
||||
getValue(): number { return 1; }
|
||||
get value(): number { return 1; }
|
||||
}
|
||||
|
||||
class MyDerived extends MyBase {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
const f1 = super.getValue();
|
||||
const f2 = super.value;
|
||||
}
|
||||
}
|
||||
|
||||
var d = new MyDerived();
|
||||
var f3 = d.value;
|
||||
|
||||
class A {
|
||||
private _property: string;
|
||||
get property() { return this._property; }
|
||||
set property(value: string) { this._property = value }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
set property(value: string) {
|
||||
super.property = value + " addition";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
declare module "a" {
|
||||
export default 0
|
||||
export var a;
|
||||
export type a = typeof a;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Example from #6037
|
||||
|
||||
function fold<a, r>(values: a[], result: r, fold: (result: r, value: a) => r): r {
|
||||
for (let value of values) {
|
||||
result = fold(result, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function append<a, b extends a>(values: a[], value: b): a[] {
|
||||
values.push(value);
|
||||
return values;
|
||||
}
|
||||
|
||||
fold(
|
||||
[1, 2, 3],
|
||||
[] as [string, string][],
|
||||
(result, value) => append(
|
||||
result,
|
||||
["", ""]
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
// Check that type parameter constraints are properly instantiated
|
||||
|
||||
interface Mapper<T> {
|
||||
map<U extends T, V extends U[]>(f: (item: T) => U): V;
|
||||
}
|
||||
|
||||
var m: Mapper<string>;
|
||||
var a = m.map((x: string) => x); // string[]
|
||||
@@ -0,0 +1,5 @@
|
||||
new class {
|
||||
hi() {
|
||||
return "Hi!";
|
||||
}
|
||||
}().hi();
|
||||
@@ -0,0 +1,141 @@
|
||||
// @declaration: true
|
||||
class RoyalGuard {
|
||||
isLeader(): this is LeadGuard {
|
||||
return this instanceof LeadGuard;
|
||||
}
|
||||
isFollower(): this is FollowerGuard {
|
||||
return this instanceof FollowerGuard;
|
||||
}
|
||||
}
|
||||
|
||||
class LeadGuard extends RoyalGuard {
|
||||
lead(): void {};
|
||||
}
|
||||
|
||||
class FollowerGuard extends RoyalGuard {
|
||||
follow(): void {};
|
||||
}
|
||||
|
||||
let a: RoyalGuard = new FollowerGuard();
|
||||
if (a.isLeader()) {
|
||||
a.lead();
|
||||
}
|
||||
else if (a.isFollower()) {
|
||||
a.follow();
|
||||
}
|
||||
|
||||
interface GuardInterface extends RoyalGuard {}
|
||||
|
||||
let b: GuardInterface;
|
||||
if (b.isLeader()) {
|
||||
b.lead();
|
||||
}
|
||||
else if (b.isFollower()) {
|
||||
b.follow();
|
||||
}
|
||||
|
||||
if (((a.isLeader)())) {
|
||||
a.lead();
|
||||
}
|
||||
else if (((a).isFollower())) {
|
||||
a.follow();
|
||||
}
|
||||
|
||||
if (((a["isLeader"])())) {
|
||||
a.lead();
|
||||
}
|
||||
else if (((a)["isFollower"]())) {
|
||||
a.follow();
|
||||
}
|
||||
|
||||
var holder2 = {a};
|
||||
|
||||
if (holder2.a.isLeader()) {
|
||||
holder2.a;
|
||||
}
|
||||
else {
|
||||
holder2.a;
|
||||
}
|
||||
|
||||
class ArrowGuard {
|
||||
isElite = (): this is ArrowElite => {
|
||||
return this instanceof ArrowElite;
|
||||
}
|
||||
isMedic = (): this is ArrowMedic => {
|
||||
return this instanceof ArrowMedic;
|
||||
}
|
||||
}
|
||||
|
||||
class ArrowElite extends ArrowGuard {
|
||||
defend(): void {}
|
||||
}
|
||||
|
||||
class ArrowMedic extends ArrowGuard {
|
||||
heal(): void {}
|
||||
}
|
||||
|
||||
let guard = new ArrowGuard();
|
||||
if (guard.isElite()) {
|
||||
guard.defend();
|
||||
}
|
||||
else if (guard.isMedic()) {
|
||||
guard.heal();
|
||||
}
|
||||
|
||||
interface Supplies {
|
||||
spoiled: boolean;
|
||||
}
|
||||
|
||||
interface Sundries {
|
||||
broken: boolean;
|
||||
}
|
||||
|
||||
interface Crate<T> {
|
||||
contents: T;
|
||||
volume: number;
|
||||
isSupplies(): this is Crate<Supplies>;
|
||||
isSundries(): this is Crate<Sundries>;
|
||||
}
|
||||
|
||||
let crate: Crate<{}>;
|
||||
|
||||
if (crate.isSundries()) {
|
||||
crate.contents.broken = true;
|
||||
}
|
||||
else if (crate.isSupplies()) {
|
||||
crate.contents.spoiled = true;
|
||||
}
|
||||
|
||||
// Matching guards should be assignable
|
||||
|
||||
a.isFollower = b.isFollower;
|
||||
a.isLeader = b.isLeader;
|
||||
|
||||
class MimicGuard {
|
||||
isLeader(): this is MimicLeader { return this instanceof MimicLeader; };
|
||||
isFollower(): this is MimicFollower { return this instanceof MimicFollower; };
|
||||
}
|
||||
|
||||
class MimicLeader extends MimicGuard {
|
||||
lead(): void {}
|
||||
}
|
||||
|
||||
class MimicFollower extends MimicGuard {
|
||||
follow(): void {}
|
||||
}
|
||||
|
||||
let mimic = new MimicGuard();
|
||||
|
||||
a.isLeader = mimic.isLeader;
|
||||
a.isFollower = mimic.isFollower;
|
||||
|
||||
if (mimic.isFollower()) {
|
||||
mimic.follow();
|
||||
mimic.isFollower = a.isFollower;
|
||||
}
|
||||
|
||||
|
||||
interface MimicGuardInterface {
|
||||
isLeader(): this is LeadGuard;
|
||||
isFollower(): this is FollowerGuard;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// @declaration: true
|
||||
class RoyalGuard {
|
||||
isLeader(): this is LeadGuard {
|
||||
return this instanceof LeadGuard;
|
||||
}
|
||||
isFollower(): this is FollowerGuard {
|
||||
return this instanceof FollowerGuard;
|
||||
}
|
||||
}
|
||||
|
||||
class LeadGuard extends RoyalGuard {
|
||||
lead(): void {};
|
||||
}
|
||||
|
||||
class FollowerGuard extends RoyalGuard {
|
||||
follow(): void {};
|
||||
}
|
||||
|
||||
interface GuardInterface extends RoyalGuard {}
|
||||
let a: RoyalGuard = new FollowerGuard();
|
||||
let b: GuardInterface = new LeadGuard();
|
||||
|
||||
// Mismatched guards shouldn't be assignable
|
||||
b.isFollower = b.isLeader;
|
||||
b.isLeader = b.isFollower;
|
||||
|
||||
a.isFollower = a.isLeader;
|
||||
a.isLeader = a.isFollower;
|
||||
|
||||
function invalidGuard(c: any): this is number {
|
||||
return false;
|
||||
}
|
||||
|
||||
let c: number | number[];
|
||||
if (invalidGuard(c)) {
|
||||
c;
|
||||
}
|
||||
else {
|
||||
c;
|
||||
}
|
||||
|
||||
let holder = {invalidGuard};
|
||||
|
||||
if (holder.invalidGuard(c)) {
|
||||
c;
|
||||
holder;
|
||||
}
|
||||
else {
|
||||
c;
|
||||
holder;
|
||||
}
|
||||
|
||||
let detached = a.isFollower;
|
||||
|
||||
if (detached()) {
|
||||
a.follow();
|
||||
}
|
||||
else {
|
||||
a.lead();
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// @target: es5
|
||||
// @declaration: true
|
||||
// There's a 'File' class in the stdlib, wrap with a namespace to avoid collision
|
||||
namespace Test {
|
||||
export class FileSystemObject {
|
||||
isFSO: this is FileSystemObject;
|
||||
get isFile(): this is File {
|
||||
return this instanceof File;
|
||||
}
|
||||
set isFile(param) {
|
||||
// noop
|
||||
}
|
||||
get isDirectory(): this is Directory {
|
||||
return this instanceof Directory;
|
||||
}
|
||||
isNetworked: this is (Networked & this);
|
||||
constructor(public path: string) {}
|
||||
}
|
||||
|
||||
export class File extends FileSystemObject {
|
||||
constructor(path: string, public content: string) { super(path); }
|
||||
}
|
||||
export class Directory extends FileSystemObject {
|
||||
children: FileSystemObject[];
|
||||
}
|
||||
export interface Networked {
|
||||
host: string;
|
||||
}
|
||||
|
||||
let file: FileSystemObject = new File("foo/bar.txt", "foo");
|
||||
file.isNetworked = false;
|
||||
file.isFSO = file.isFile;
|
||||
file.isFile = true;
|
||||
let x = file.isFile;
|
||||
if (file.isFile) {
|
||||
file.content;
|
||||
if (file.isNetworked) {
|
||||
file.host;
|
||||
file.content;
|
||||
}
|
||||
}
|
||||
else if (file.isDirectory) {
|
||||
file.children;
|
||||
}
|
||||
else if (file.isNetworked) {
|
||||
file.host;
|
||||
}
|
||||
|
||||
interface GenericLeadGuard<T> extends GenericGuard<T> {
|
||||
lead(): void;
|
||||
}
|
||||
|
||||
interface GenericFollowerGuard<T> extends GenericGuard<T> {
|
||||
follow(): void;
|
||||
}
|
||||
|
||||
interface GenericGuard<T> {
|
||||
target: T;
|
||||
isLeader: this is (GenericLeadGuard<T>);
|
||||
isFollower: this is GenericFollowerGuard<T>;
|
||||
}
|
||||
|
||||
let guard: GenericGuard<File>;
|
||||
if (guard.isLeader) {
|
||||
guard.lead();
|
||||
}
|
||||
else if (guard.isFollower) {
|
||||
guard.follow();
|
||||
}
|
||||
|
||||
interface SpecificGuard {
|
||||
isMoreSpecific: this is MoreSpecificGuard;
|
||||
}
|
||||
|
||||
interface MoreSpecificGuard extends SpecificGuard {
|
||||
do(): void;
|
||||
}
|
||||
|
||||
let general: SpecificGuard;
|
||||
if (general.isMoreSpecific) {
|
||||
general.do();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// @target: es5
|
||||
// @declaration: true
|
||||
// There's a 'File' class in the stdlib, wrap with a namespace to avoid collision
|
||||
namespace Test {
|
||||
export class FileSystemObject {
|
||||
isFSO: this is FileSystemObject;
|
||||
get isFile(): this is File {
|
||||
return this instanceof File;
|
||||
}
|
||||
set isFile(param) {
|
||||
// noop
|
||||
}
|
||||
get isDirectory(): this is Directory {
|
||||
return this instanceof Directory;
|
||||
}
|
||||
isNetworked: this is (Networked & this);
|
||||
constructor(public path: string) {}
|
||||
}
|
||||
|
||||
export class File extends FileSystemObject {
|
||||
constructor(path: string, public content: string) { super(path); }
|
||||
}
|
||||
export class Directory extends FileSystemObject {
|
||||
children: FileSystemObject[];
|
||||
}
|
||||
export interface Networked {
|
||||
host: string;
|
||||
}
|
||||
|
||||
let file: FileSystemObject = new File("foo/bar.txt", "foo");
|
||||
file.isNetworked = file.isFile;
|
||||
file.isFSO = file.isNetworked;
|
||||
file.isFile = file.isFSO;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//@jsx: preserve
|
||||
|
||||
//@filename: file.tsx
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
// This should be a parse error
|
||||
const class1 = "foo";
|
||||
const class2 = "bar";
|
||||
const elem = <div className={class1, class2}/>;
|
||||
@@ -0,0 +1,46 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// Assignments to the 'prototype' property of a function create a class
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: myMod.js
|
||||
//// function myCtor(x) {
|
||||
//// }
|
||||
//// myCtor.prototype.foo = function() { return 32 };
|
||||
//// myCtor.prototype.bar = function() { return '' };
|
||||
////
|
||||
//// var m = new myCtor(10);
|
||||
//// m/*1*/
|
||||
//// var a = m.foo;
|
||||
//// a/*2*/
|
||||
//// var b = a();
|
||||
//// b/*3*/
|
||||
//// var c = m.bar();
|
||||
//// c/*4*/
|
||||
|
||||
|
||||
// Members of the class instance
|
||||
goTo.marker('1');
|
||||
edit.insert('.');
|
||||
verify.memberListContains('foo', undefined, undefined, 'property');
|
||||
verify.memberListContains('bar', undefined, undefined, 'property');
|
||||
edit.backspace();
|
||||
|
||||
// Members of a class method (1)
|
||||
goTo.marker('2');
|
||||
edit.insert('.');
|
||||
verify.memberListContains('length', undefined, undefined, 'property');
|
||||
edit.backspace();
|
||||
|
||||
// Members of the invocation of a class method (1)
|
||||
goTo.marker('3');
|
||||
edit.insert('.');
|
||||
verify.memberListContains('toFixed', undefined, undefined, 'method');
|
||||
verify.not.memberListContains('substr', undefined, undefined, 'method');
|
||||
edit.backspace();
|
||||
|
||||
// Members of the invocation of a class method (2)
|
||||
goTo.marker('4');
|
||||
edit.insert('.');
|
||||
verify.memberListContains('substr', undefined, undefined, 'method');
|
||||
verify.not.memberListContains('toFixed', undefined, undefined, 'method');
|
||||
@@ -0,0 +1,36 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// Assignments to 'this' in the constructorish body create
|
||||
// properties with those names
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: myMod.js
|
||||
//// function myCtor(x) {
|
||||
//// this.qua = 10;
|
||||
//// }
|
||||
//// myCtor.prototype.foo = function() { return 32 };
|
||||
//// myCtor.prototype.bar = function() { return '' };
|
||||
////
|
||||
//// var m = new myCtor(10);
|
||||
//// m/*1*/
|
||||
//// var x = m.qua;
|
||||
//// x/*2*/
|
||||
//// myCtor/*3*/
|
||||
|
||||
// Verify the instance property exists
|
||||
goTo.marker('1');
|
||||
edit.insert('.');
|
||||
verify.completionListContains('qua', undefined, undefined, 'property');
|
||||
edit.backspace();
|
||||
|
||||
// Verify the type of the instance property
|
||||
goTo.marker('2');
|
||||
edit.insert('.');
|
||||
verify.completionListContains('toFixed', undefined, undefined, 'method');
|
||||
|
||||
goTo.marker('3');
|
||||
edit.insert('.');
|
||||
// Make sure symbols don't leak out into the constructor
|
||||
verify.completionListContains('qua', undefined, undefined, 'warning');
|
||||
verify.completionListContains('foo', undefined, undefined, 'warning');
|
||||
verify.completionListContains('bar', undefined, undefined, 'warning');
|
||||
@@ -0,0 +1,20 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// Inside an inferred method body, the type of 'this' is the class type
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: myMod.js
|
||||
//// function myCtor(x) {
|
||||
//// this.qua = 10;
|
||||
//// }
|
||||
//// myCtor.prototype.foo = function() { return this/**/; };
|
||||
//// myCtor.prototype.bar = function() { return '' };
|
||||
////
|
||||
|
||||
goTo.marker();
|
||||
edit.insert('.');
|
||||
|
||||
// Check members of the function
|
||||
verify.completionListContains('foo', undefined, undefined, 'property');
|
||||
verify.completionListContains('bar', undefined, undefined, 'property');
|
||||
verify.completionListContains('qua', undefined, undefined, 'property');
|
||||
@@ -0,0 +1,21 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// Check for any odd symbol leakage
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: myMod.js
|
||||
//// function myCtor(x) {
|
||||
//// this.qua = 10;
|
||||
//// }
|
||||
//// myCtor.prototype.foo = function() { return 32 };
|
||||
//// myCtor.prototype.bar = function() { return '' };
|
||||
////
|
||||
//// myCtor/*1*/
|
||||
|
||||
goTo.marker('1');
|
||||
edit.insert('.');
|
||||
|
||||
// Check members of the function
|
||||
verify.completionListContains('foo', undefined, undefined, 'warning');
|
||||
verify.completionListContains('bar', undefined, undefined, 'warning');
|
||||
verify.completionListContains('qua', undefined, undefined, 'warning');
|
||||
@@ -0,0 +1,19 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// No prototype assignments are needed to enable class inference
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: myMod.js
|
||||
//// function myCtor() {
|
||||
//// this.foo = 'hello';
|
||||
//// this.bar = 10;
|
||||
//// }
|
||||
//// let x = new myCtor();
|
||||
//// x/**/
|
||||
|
||||
goTo.marker();
|
||||
edit.insert('.');
|
||||
|
||||
// Check members of the function
|
||||
verify.completionListContains('foo', undefined, undefined, 'property');
|
||||
verify.completionListContains('bar', undefined, undefined, 'property');
|
||||
@@ -0,0 +1,80 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// class RoyalGuard {
|
||||
//// isLeader(): this is LeadGuard {
|
||||
//// return this instanceof LeadGuard;
|
||||
//// }
|
||||
//// isFollower(): this is FollowerGuard {
|
||||
//// return this instanceof FollowerGuard;
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// class LeadGuard extends RoyalGuard {
|
||||
//// lead(): void {};
|
||||
//// }
|
||||
////
|
||||
//// class FollowerGuard extends RoyalGuard {
|
||||
//// follow(): void {};
|
||||
//// }
|
||||
////
|
||||
//// let a: RoyalGuard = new FollowerGuard();
|
||||
//// if (a.is/*1*/Leader()) {
|
||||
//// a./*2*/;
|
||||
//// }
|
||||
//// else if (a.is/*3*/Follower()) {
|
||||
//// a./*4*/;
|
||||
//// }
|
||||
////
|
||||
//// interface GuardInterface {
|
||||
//// isLeader(): this is LeadGuard;
|
||||
//// isFollower(): this is FollowerGuard;
|
||||
//// }
|
||||
////
|
||||
//// let b: GuardInterface;
|
||||
//// if (b.is/*5*/Leader()) {
|
||||
//// b./*6*/;
|
||||
//// }
|
||||
//// else if (b.is/*7*/Follower()) {
|
||||
//// b./*8*/;
|
||||
//// }
|
||||
////
|
||||
//// if (((a.isLeader)())) {
|
||||
//// a./*9*/;
|
||||
//// }
|
||||
//// else if (((a).isFollower())) {
|
||||
//// a./*10*/;
|
||||
//// }
|
||||
////
|
||||
//// if (((a["isLeader"])())) {
|
||||
//// a./*11*/;
|
||||
//// }
|
||||
//// else if (((a)["isFollower"]())) {
|
||||
//// a./*12*/;
|
||||
//// }
|
||||
////
|
||||
//// let leader/*13*/Status = a.isLeader();
|
||||
//// function isLeaderGuard(g: RoyalGuard) {
|
||||
//// return g.isLeader();
|
||||
//// }
|
||||
//// let checked/*14*/LeaderStatus = isLeader/*15*/Guard(a);
|
||||
|
||||
|
||||
goTo.marker("2");
|
||||
verify.completionListContains("lead");
|
||||
goTo.marker("4");
|
||||
verify.completionListContains("follow");
|
||||
|
||||
goTo.marker("6");
|
||||
verify.completionListContains("lead");
|
||||
goTo.marker("8");
|
||||
verify.completionListContains("follow");
|
||||
|
||||
goTo.marker("9");
|
||||
verify.completionListContains("lead");
|
||||
goTo.marker("10");
|
||||
verify.completionListContains("follow");
|
||||
|
||||
goTo.marker("11");
|
||||
verify.completionListContains("lead");
|
||||
goTo.marker("12");
|
||||
verify.completionListContains("follow");
|
||||
@@ -0,0 +1,77 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// class RoyalGuard {
|
||||
//// isLeader(): this is LeadGuard {
|
||||
//// return this instanceof LeadGuard;
|
||||
//// }
|
||||
//// isFollower(): this is FollowerGuard {
|
||||
//// return this instanceof FollowerGuard;
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// class LeadGuard extends RoyalGuard {
|
||||
//// lead(): void {};
|
||||
//// }
|
||||
////
|
||||
//// class FollowerGuard extends RoyalGuard {
|
||||
//// follow(): void {};
|
||||
//// }
|
||||
////
|
||||
//// let a: RoyalGuard = new FollowerGuard();
|
||||
//// if (a.is/*1*/Leader()) {
|
||||
//// a./*2*/;
|
||||
//// }
|
||||
//// else if (a.is/*3*/Follower()) {
|
||||
//// a./*4*/;
|
||||
//// }
|
||||
////
|
||||
//// interface GuardInterface {
|
||||
//// isLeader(): this is LeadGuard;
|
||||
//// isFollower(): this is FollowerGuard;
|
||||
//// }
|
||||
////
|
||||
//// let b: GuardInterface;
|
||||
//// if (b.is/*5*/Leader()) {
|
||||
//// b./*6*/;
|
||||
//// }
|
||||
//// else if (b.is/*7*/Follower()) {
|
||||
//// b./*8*/;
|
||||
//// }
|
||||
////
|
||||
//// if (((a.isLeader)())) {
|
||||
//// a./*9*/;
|
||||
//// }
|
||||
//// else if (((a).isFollower())) {
|
||||
//// a./*10*/;
|
||||
//// }
|
||||
////
|
||||
//// if (((a["isLeader"])())) {
|
||||
//// a./*11*/;
|
||||
//// }
|
||||
//// else if (((a)["isFollower"]())) {
|
||||
//// a./*12*/;
|
||||
//// }
|
||||
////
|
||||
//// let leader/*13*/Status = a.isLeader();
|
||||
//// function isLeaderGuard(g: RoyalGuard) {
|
||||
//// return g.isLeader();
|
||||
//// }
|
||||
//// let checked/*14*/LeaderStatus = isLeader/*15*/Guard(a);
|
||||
|
||||
|
||||
goTo.marker("1");
|
||||
verify.quickInfoIs("(method) RoyalGuard.isLeader(): this is LeadGuard");
|
||||
goTo.marker("3");
|
||||
verify.quickInfoIs("(method) RoyalGuard.isFollower(): this is FollowerGuard");
|
||||
|
||||
goTo.marker("5");
|
||||
verify.quickInfoIs("(method) GuardInterface.isLeader(): this is LeadGuard");
|
||||
goTo.marker("7");
|
||||
verify.quickInfoIs("(method) GuardInterface.isFollower(): this is FollowerGuard");
|
||||
|
||||
goTo.marker("13");
|
||||
verify.quickInfoIs("let leaderStatus: boolean");
|
||||
goTo.marker("14");
|
||||
verify.quickInfoIs("let checkedLeaderStatus: boolean");
|
||||
goTo.marker("15");
|
||||
verify.quickInfoIs("function isLeaderGuard(g: RoyalGuard): boolean");
|
||||
@@ -0,0 +1,95 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// class FileSystemObject {
|
||||
//// get is/*1*/File(): this is Item {
|
||||
//// return this instanceof Item;
|
||||
//// }
|
||||
//// set is/*2*/File(param) {
|
||||
//// // noop
|
||||
//// }
|
||||
//// get is/*3*/Directory(): this is Directory {
|
||||
//// return this instanceof Directory;
|
||||
//// }
|
||||
//// is/*4*/Networked: this is (Networked & this);
|
||||
//// constructor(public path: string) {}
|
||||
//// }
|
||||
////
|
||||
//// class Item extends FileSystemObject {
|
||||
//// constructor(path: string, public content: string) { super(path); }
|
||||
//// }
|
||||
//// class Directory extends FileSystemObject {
|
||||
//// children: FileSystemObject[];
|
||||
//// }
|
||||
//// interface Networked {
|
||||
//// host: string;
|
||||
//// }
|
||||
////
|
||||
//// interface Sundries {
|
||||
//// broken: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Supplies {
|
||||
//// spoiled: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Crate<T> {
|
||||
//// contents: T;
|
||||
//// is/*5*/Sundries: this is Crate<Sundries>;
|
||||
//// is/*6*/Supplies: this is Crate<Supplies>;
|
||||
//// is/*7*/PackedTight: this is (this & {extraContents: T});
|
||||
//// }
|
||||
////
|
||||
//// const obj: FileSystemObject = new Item("/foo", "");
|
||||
//// if (obj.is/*8*/File) {
|
||||
//// obj./*9*/;
|
||||
//// if (obj.is/*10*/Networked) {
|
||||
//// obj./*11*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.is/*12*/Directory) {
|
||||
//// obj./*13*/;
|
||||
//// if (obj.is/*14*/Networked) {
|
||||
//// obj./*15*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.is/*16*/Networked) {
|
||||
//// obj./*17*/;
|
||||
//// }
|
||||
////
|
||||
//// const crate: Crate<any>;
|
||||
//// if (crate.is/*18*/PackedTight) {
|
||||
//// crate./*19*/;
|
||||
//// }
|
||||
//// if (crate.is/*20*/Sundries) {
|
||||
//// crate.contents./*21*/;
|
||||
//// if (crate.is/*22*/PackedTight) {
|
||||
//// crate./*23*/
|
||||
//// }
|
||||
//// }
|
||||
//// if (crate.is/*24*/Supplies) {
|
||||
//// crate.contents./*25*/;
|
||||
//// if (crate.is/*26*/PackedTight) {
|
||||
//// crate./*27*/
|
||||
//// }
|
||||
//// }
|
||||
|
||||
goTo.marker("9");
|
||||
verify.completionListContains("content");
|
||||
goTo.marker("11");
|
||||
verify.completionListContains("host");
|
||||
goTo.marker("13");
|
||||
verify.completionListContains("children");
|
||||
goTo.marker("15");
|
||||
verify.completionListContains("host");
|
||||
goTo.marker("17");
|
||||
verify.completionListContains("host");
|
||||
goTo.marker("19");
|
||||
verify.completionListContains("extraContents");
|
||||
goTo.marker("21");
|
||||
verify.completionListContains("broken");
|
||||
goTo.marker("23");
|
||||
verify.completionListContains("extraContents");
|
||||
goTo.marker("25");
|
||||
verify.completionListContains("spoiled");
|
||||
goTo.marker("27");
|
||||
verify.completionListContains("extraContents");
|
||||
@@ -0,0 +1,117 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// class FileSystemObject {
|
||||
//// get is/*1*/File(): this is Item {
|
||||
//// return this instanceof Item;
|
||||
//// }
|
||||
//// set is/*2*/File(param) {
|
||||
//// // noop
|
||||
//// }
|
||||
//// get is/*3*/Directory(): this is Directory {
|
||||
//// return this instanceof Directory;
|
||||
//// }
|
||||
//// is/*4*/Networked: this is (Networked & this);
|
||||
//// constructor(public path: string) {}
|
||||
//// }
|
||||
////
|
||||
//// class Item extends FileSystemObject {
|
||||
//// constructor(path: string, public content: string) { super(path); }
|
||||
//// }
|
||||
//// class Directory extends FileSystemObject {
|
||||
//// children: FileSystemObject[];
|
||||
//// }
|
||||
//// interface Networked {
|
||||
//// host: string;
|
||||
//// }
|
||||
////
|
||||
//// interface Sundries {
|
||||
//// broken: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Supplies {
|
||||
//// spoiled: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Crate<T> {
|
||||
//// contents: T;
|
||||
//// is/*5*/Sundries: this is Crate<Sundries>;
|
||||
//// is/*6*/Supplies: this is Crate<Supplies>;
|
||||
//// is/*7*/PackedTight: this is (this & {extraContents: T});
|
||||
//// }
|
||||
////
|
||||
//// const obj: FileSystemObject = new Item("/foo", "");
|
||||
//// if (obj.is/*8*/File) {
|
||||
//// obj./*9*/;
|
||||
//// if (obj.is/*10*/Networked) {
|
||||
//// obj./*11*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.is/*12*/Directory) {
|
||||
//// obj./*13*/;
|
||||
//// if (obj.is/*14*/Networked) {
|
||||
//// obj./*15*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.is/*16*/Networked) {
|
||||
//// obj./*17*/;
|
||||
//// }
|
||||
////
|
||||
//// const crate: Crate<any>;
|
||||
//// if (crate.is/*18*/PackedTight) {
|
||||
//// crate./*19*/;
|
||||
//// }
|
||||
//// if (crate.is/*20*/Sundries) {
|
||||
//// crate.contents./*21*/;
|
||||
//// if (crate.is/*22*/PackedTight) {
|
||||
//// crate./*23*/
|
||||
//// }
|
||||
//// }
|
||||
//// if (crate.is/*24*/Supplies) {
|
||||
//// crate.contents./*25*/;
|
||||
//// if (crate.is/*26*/PackedTight) {
|
||||
//// crate./*27*/
|
||||
//// }
|
||||
//// }
|
||||
|
||||
goTo.marker("1");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isFile: this is Item");
|
||||
goTo.marker("2");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isFile: this is Item");
|
||||
goTo.marker("3");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isDirectory: this is Directory");
|
||||
goTo.marker("4");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isNetworked: this is Networked & this");
|
||||
goTo.marker("5");
|
||||
verify.quickInfoIs("(property) Crate<T>.isSundries: this is Crate<Sundries>");
|
||||
goTo.marker("6");
|
||||
verify.quickInfoIs("(property) Crate<T>.isSupplies: this is Crate<Supplies>");
|
||||
goTo.marker("7");
|
||||
verify.quickInfoIs(`(property) Crate<T>.isPackedTight: this is this & {
|
||||
extraContents: T;
|
||||
}`);
|
||||
goTo.marker("8");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isFile: this is Item");
|
||||
goTo.marker("10");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isNetworked: this is Networked & Item");
|
||||
goTo.marker("12");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isDirectory: this is Directory");
|
||||
goTo.marker("14");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isNetworked: this is Networked & Directory");
|
||||
goTo.marker("16");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isNetworked: this is Networked & FileSystemObject");
|
||||
goTo.marker("18");
|
||||
verify.quickInfoIs(`(property) Crate<any>.isPackedTight: this is Crate<any> & {
|
||||
extraContents: any;
|
||||
}`);
|
||||
goTo.marker("20");
|
||||
verify.quickInfoIs("(property) Crate<any>.isSundries: this is Crate<Sundries>");
|
||||
goTo.marker("22");
|
||||
verify.quickInfoIs(`(property) Crate<Sundries>.isPackedTight: this is Crate<Sundries> & {
|
||||
extraContents: Sundries;
|
||||
}`);
|
||||
goTo.marker("24");
|
||||
verify.quickInfoIs("(property) Crate<any>.isSupplies: this is Crate<Supplies>");
|
||||
goTo.marker("26");
|
||||
verify.quickInfoIs(`(property) Crate<Supplies>.isPackedTight: this is Crate<Supplies> & {
|
||||
extraContents: Supplies;
|
||||
}`);
|
||||
@@ -256,7 +256,7 @@ var x = 0;`,
|
||||
` ], MyClass);\n` +
|
||||
` return MyClass;\n` +
|
||||
` var _a;\n` +
|
||||
`})();\n` +
|
||||
`}());\n` +
|
||||
`exports.MyClass = MyClass;\n`;
|
||||
|
||||
test(input,
|
||||
|
||||
Reference in New Issue
Block a user