Merge branch 'master' into type-guard-narrowing

This commit is contained in:
Wesley Wigham
2015-11-17 13:50:56 -08:00
107 changed files with 4177 additions and 1680 deletions

View File

@@ -1,6 +1,40 @@
//// [ambientClassDeclarationWithExtends.ts]
//// [tests/cases/compiler/ambientClassDeclarationWithExtends.ts] ////
//// [ambientClassDeclarationExtends_singleFile.ts]
declare class A { }
declare class B extends A { }
declare class C {
public foo;
}
namespace D { var x; }
declare class D extends C { }
var d: C = new D();
//// [ambientClassDeclarationExtends_file1.ts]
declare class E {
public bar;
}
namespace F { var y; }
//// [ambientClassDeclarationExtends_file2.ts]
declare class F extends E { }
var f: E = new F();
//// [ambientClassDeclarationWithExtends.js]
//// [ambientClassDeclarationExtends_singleFile.js]
var D;
(function (D) {
var x;
})(D || (D = {}));
var d = new D();
//// [ambientClassDeclarationExtends_file1.js]
var F;
(function (F) {
var y;
})(F || (F = {}));
//// [ambientClassDeclarationExtends_file2.js]
var f = new F();

View File

@@ -1,8 +1,50 @@
=== tests/cases/compiler/ambientClassDeclarationWithExtends.ts ===
=== tests/cases/compiler/ambientClassDeclarationExtends_singleFile.ts ===
declare class A { }
>A : Symbol(A, Decl(ambientClassDeclarationWithExtends.ts, 0, 0))
>A : Symbol(A, Decl(ambientClassDeclarationExtends_singleFile.ts, 0, 0))
declare class B extends A { }
>B : Symbol(B, Decl(ambientClassDeclarationWithExtends.ts, 0, 19))
>A : Symbol(A, Decl(ambientClassDeclarationWithExtends.ts, 0, 0))
>B : Symbol(B, Decl(ambientClassDeclarationExtends_singleFile.ts, 0, 19))
>A : Symbol(A, Decl(ambientClassDeclarationExtends_singleFile.ts, 0, 0))
declare class C {
>C : Symbol(C, Decl(ambientClassDeclarationExtends_singleFile.ts, 1, 29))
public foo;
>foo : Symbol(foo, Decl(ambientClassDeclarationExtends_singleFile.ts, 3, 17))
}
namespace D { var x; }
>D : Symbol(D, Decl(ambientClassDeclarationExtends_singleFile.ts, 5, 1), Decl(ambientClassDeclarationExtends_singleFile.ts, 6, 22))
>x : Symbol(x, Decl(ambientClassDeclarationExtends_singleFile.ts, 6, 17))
declare class D extends C { }
>D : Symbol(D, Decl(ambientClassDeclarationExtends_singleFile.ts, 5, 1), Decl(ambientClassDeclarationExtends_singleFile.ts, 6, 22))
>C : Symbol(C, Decl(ambientClassDeclarationExtends_singleFile.ts, 1, 29))
var d: C = new D();
>d : Symbol(d, Decl(ambientClassDeclarationExtends_singleFile.ts, 9, 3))
>C : Symbol(C, Decl(ambientClassDeclarationExtends_singleFile.ts, 1, 29))
>D : Symbol(D, Decl(ambientClassDeclarationExtends_singleFile.ts, 5, 1), Decl(ambientClassDeclarationExtends_singleFile.ts, 6, 22))
=== tests/cases/compiler/ambientClassDeclarationExtends_file1.ts ===
declare class E {
>E : Symbol(E, Decl(ambientClassDeclarationExtends_file1.ts, 0, 0))
public bar;
>bar : Symbol(bar, Decl(ambientClassDeclarationExtends_file1.ts, 1, 17))
}
namespace F { var y; }
>F : Symbol(F, Decl(ambientClassDeclarationExtends_file1.ts, 3, 1), Decl(ambientClassDeclarationExtends_file2.ts, 0, 0))
>y : Symbol(y, Decl(ambientClassDeclarationExtends_file1.ts, 4, 17))
=== tests/cases/compiler/ambientClassDeclarationExtends_file2.ts ===
declare class F extends E { }
>F : Symbol(F, Decl(ambientClassDeclarationExtends_file1.ts, 3, 1), Decl(ambientClassDeclarationExtends_file2.ts, 0, 0))
>E : Symbol(E, Decl(ambientClassDeclarationExtends_file1.ts, 0, 0))
var f: E = new F();
>f : Symbol(f, Decl(ambientClassDeclarationExtends_file2.ts, 2, 3))
>E : Symbol(E, Decl(ambientClassDeclarationExtends_file1.ts, 0, 0))
>F : Symbol(F, Decl(ambientClassDeclarationExtends_file1.ts, 3, 1), Decl(ambientClassDeclarationExtends_file2.ts, 0, 0))

View File

@@ -1,4 +1,4 @@
=== tests/cases/compiler/ambientClassDeclarationWithExtends.ts ===
=== tests/cases/compiler/ambientClassDeclarationExtends_singleFile.ts ===
declare class A { }
>A : A
@@ -6,3 +6,47 @@ declare class B extends A { }
>B : B
>A : A
declare class C {
>C : C
public foo;
>foo : any
}
namespace D { var x; }
>D : typeof D
>x : any
declare class D extends C { }
>D : D
>C : C
var d: C = new D();
>d : C
>C : C
>new D() : D
>D : typeof D
=== tests/cases/compiler/ambientClassDeclarationExtends_file1.ts ===
declare class E {
>E : E
public bar;
>bar : any
}
namespace F { var y; }
>F : typeof F
>y : any
=== tests/cases/compiler/ambientClassDeclarationExtends_file2.ts ===
declare class F extends E { }
>F : F
>E : E
var f: E = new F();
>f : E
>E : E
>new F() : F
>F : typeof F

View File

@@ -0,0 +1,27 @@
//// [checkSwitchStatementIfCaseTypeIsString.ts]
declare function use(a: any): void;
class A {
doIt(x: Array<string>): void {
x.forEach((v) => {
switch(v) {
case "test": use(this);
}
});
}
}
//// [checkSwitchStatementIfCaseTypeIsString.js]
var A = (function () {
function A() {
}
A.prototype.doIt = function (x) {
var _this = this;
x.forEach(function (v) {
switch (v) {
case "test": use(_this);
}
});
};
return A;
})();

View File

@@ -0,0 +1,29 @@
=== tests/cases/compiler/checkSwitchStatementIfCaseTypeIsString.ts ===
declare function use(a: any): void;
>use : Symbol(use, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 0))
>a : Symbol(a, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 21))
class A {
>A : Symbol(A, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 35))
doIt(x: Array<string>): void {
>doIt : Symbol(doIt, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 2, 9))
>x : Symbol(x, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 3, 9))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
x.forEach((v) => {
>x.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 3, 9))
>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --))
>v : Symbol(v, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 4, 19))
switch(v) {
>v : Symbol(v, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 4, 19))
case "test": use(this);
>use : Symbol(use, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 0))
>this : Symbol(A, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 35))
}
});
}
}

View File

@@ -0,0 +1,33 @@
=== tests/cases/compiler/checkSwitchStatementIfCaseTypeIsString.ts ===
declare function use(a: any): void;
>use : (a: any) => void
>a : any
class A {
>A : A
doIt(x: Array<string>): void {
>doIt : (x: string[]) => void
>x : string[]
>Array : T[]
x.forEach((v) => {
>x.forEach((v) => { switch(v) { case "test": use(this); } }) : void
>x.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>x : string[]
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>(v) => { switch(v) { case "test": use(this); } } : (v: string) => void
>v : string
switch(v) {
>v : string
case "test": use(this);
>"test" : string
>use(this) : void
>use : (a: any) => void
>this : this
}
});
}
}

View File

@@ -17,9 +17,9 @@ declare class Bar {
EmitSkipped: false
FileName : tests/cases/fourslash/inputFile2.js.map
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,KAAC,IAAI,GAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,IAAC,IAAI,EAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js
var y = "my div";
var x = React.createElement("div", {"name": y});
var x = React.createElement("div", {name: y});
//# sourceMappingURL=inputFile2.js.mapFileName : tests/cases/fourslash/inputFile2.d.ts
declare var y: string;
declare var x: any;

View File

@@ -1,12 +1,10 @@
error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.
tests/cases/compiler/inlineSourceMap2.ts(5,1): error TS2304: Cannot find name 'console'.
!!! error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
!!! error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
!!! error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.
==== tests/cases/compiler/inlineSourceMap2.ts (1 errors) ====
// configuration errors

View File

@@ -9,6 +9,6 @@ declare var React: any;
//// [keywordInJsxIdentifier.js]
React.createElement("foo", {"class-id": true});
React.createElement("foo", {"class": true});
React.createElement("foo", {class: true});
React.createElement("foo", {"class-id": "1"});
React.createElement("foo", {"class": "1"});
React.createElement("foo", {class: "1"});

View File

@@ -0,0 +1,27 @@
tests/cases/compiler/mixedStaticAndInstanceClassMembers.ts(4,5): error TS2387: Function overload must be static.
tests/cases/compiler/mixedStaticAndInstanceClassMembers.ts(12,12): error TS2388: Function overload must not be static.
tests/cases/compiler/mixedStaticAndInstanceClassMembers.ts(13,5): error TS2387: Function overload must be static.
==== tests/cases/compiler/mixedStaticAndInstanceClassMembers.ts (3 errors) ====
class A {
f() {}
static m1 (a: string): void;
m1 (a: number): void;
~~
!!! error TS2387: Function overload must be static.
m1 (a: any): void {
}
}
class B {
f() {}
m1 (a: string): void;
static m1 (a: number): void;
~~
!!! error TS2388: Function overload must not be static.
m1 (a: any): void {
~~
!!! error TS2387: Function overload must be static.
}
}

View File

@@ -0,0 +1,34 @@
//// [mixedStaticAndInstanceClassMembers.ts]
class A {
f() {}
static m1 (a: string): void;
m1 (a: number): void;
m1 (a: any): void {
}
}
class B {
f() {}
m1 (a: string): void;
static m1 (a: number): void;
m1 (a: any): void {
}
}
//// [mixedStaticAndInstanceClassMembers.js]
var A = (function () {
function A() {
}
A.prototype.f = function () { };
A.prototype.m1 = function (a) {
};
return A;
})();
var B = (function () {
function B() {
}
B.prototype.f = function () { };
B.prototype.m1 = function (a) {
};
return B;
})();

View File

@@ -0,0 +1,23 @@
tests/cases/compiler/nonMergedDeclarationsAndOverloads.ts(2,5): error TS2300: Duplicate identifier 'm1'.
tests/cases/compiler/nonMergedDeclarationsAndOverloads.ts(4,5): error TS2300: Duplicate identifier 'm1'.
tests/cases/compiler/nonMergedDeclarationsAndOverloads.ts(5,5): error TS2300: Duplicate identifier 'm1'.
tests/cases/compiler/nonMergedDeclarationsAndOverloads.ts(6,5): error TS2300: Duplicate identifier 'm1'.
==== tests/cases/compiler/nonMergedDeclarationsAndOverloads.ts (4 errors) ====
class A {
m1: string;
~~
!!! error TS2300: Duplicate identifier 'm1'.
f() {}
m1 (a: string): void;
~~
!!! error TS2300: Duplicate identifier 'm1'.
m1 (a: number): void;
~~
!!! error TS2300: Duplicate identifier 'm1'.
m1 (a: any): void {
~~
!!! error TS2300: Duplicate identifier 'm1'.
}
}

View File

@@ -0,0 +1,19 @@
//// [nonMergedDeclarationsAndOverloads.ts]
class A {
m1: string;
f() {}
m1 (a: string): void;
m1 (a: number): void;
m1 (a: any): void {
}
}
//// [nonMergedDeclarationsAndOverloads.js]
var A = (function () {
function A() {
}
A.prototype.f = function () { };
A.prototype.m1 = function (a) {
};
return A;
})();

View File

@@ -0,0 +1,20 @@
tests/cases/compiler/nonMergedOverloads.ts(1,5): error TS2300: Duplicate identifier 'f'.
tests/cases/compiler/nonMergedOverloads.ts(3,17): error TS1148: Cannot compile modules unless the '--module' flag is provided.
tests/cases/compiler/nonMergedOverloads.ts(3,17): error TS2300: Duplicate identifier 'f'.
tests/cases/compiler/nonMergedOverloads.ts(4,17): error TS2300: Duplicate identifier 'f'.
==== tests/cases/compiler/nonMergedOverloads.ts (4 errors) ====
var f = 10;
~
!!! error TS2300: Duplicate identifier 'f'.
export function f();
~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided.
~
!!! error TS2300: Duplicate identifier 'f'.
export function f() {
~
!!! error TS2300: Duplicate identifier 'f'.
}

View File

@@ -0,0 +1,12 @@
//// [nonMergedOverloads.ts]
var f = 10;
export function f();
export function f() {
}
//// [nonMergedOverloads.js]
var f = 10;
function f() {
}
exports.f = f;

View File

@@ -0,0 +1,9 @@
error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'.
error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'.
!!! error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
==== tests/cases/compiler/optionsInlineSourceMapMapRoot.ts (0 errors) ====
var a = 10;

View File

@@ -0,0 +1,7 @@
//// [optionsInlineSourceMapMapRoot.ts]
var a = 10;
//// [optionsInlineSourceMapMapRoot.js]
var a = 10;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcE1hcFJvb3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9vcHRpb25zSW5saW5lU291cmNlTWFwTWFwUm9vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMifQ==

View File

@@ -0,0 +1,33 @@
===================================================================
JsFile: optionsInlineSourceMapMapRoot.js
mapUrl: local/optionsInlineSourceMapMapRoot.js.map
sourceRoot:
sources: ../optionsInlineSourceMapMapRoot.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/compiler/optionsInlineSourceMapMapRoot.js
sourceFile:../optionsInlineSourceMapMapRoot.ts
-------------------------------------------------------------------
>>>var a = 10;
1 >
2 >^^^^
3 > ^
4 > ^^^
5 > ^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >var
3 > a
4 > =
5 > 10
6 > ;
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
---
>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcE1hcFJvb3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9vcHRpb25zSW5saW5lU291cmNlTWFwTWFwUm9vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMifQ==

View File

@@ -0,0 +1,7 @@
//// [optionsInlineSourceMapSourceRoot.ts]
var a = 10;
//// [optionsInlineSourceMapSourceRoot.js]
var a = 10;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcFNvdXJjZVJvb3QuanMiLCJzb3VyY2VSb290IjoibG9jYWwvIiwic291cmNlcyI6WyJvcHRpb25zSW5saW5lU291cmNlTWFwU291cmNlUm9vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMifQ==

View File

@@ -0,0 +1,33 @@
===================================================================
JsFile: optionsInlineSourceMapSourceRoot.js
mapUrl: optionsInlineSourceMapSourceRoot.js.map
sourceRoot: local/
sources: optionsInlineSourceMapSourceRoot.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/compiler/optionsInlineSourceMapSourceRoot.js
sourceFile:optionsInlineSourceMapSourceRoot.ts
-------------------------------------------------------------------
>>>var a = 10;
1 >
2 >^^^^
3 > ^
4 > ^^^
5 > ^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >var
3 > a
4 > =
5 > 10
6 > ;
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
---
>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcFNvdXJjZVJvb3QuanMiLCJzb3VyY2VSb290IjoibG9jYWwvIiwic291cmNlcyI6WyJvcHRpb25zSW5saW5lU291cmNlTWFwU291cmNlUm9vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMifQ==

View File

@@ -0,0 +1,5 @@
=== tests/cases/compiler/optionsInlineSourceMapSourceRoot.ts ===
var a = 10;
>a : Symbol(a, Decl(optionsInlineSourceMapSourceRoot.ts, 1, 3))

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/optionsInlineSourceMapSourceRoot.ts ===
var a = 10;
>a : number
>10 : number

View File

@@ -0,0 +1,7 @@
error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
!!! error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
==== tests/cases/compiler/optionsInlineSourceMapSourcemap.ts (0 errors) ====
var a = 10;

View File

@@ -0,0 +1,7 @@
//// [optionsInlineSourceMapSourcemap.ts]
var a = 10;
//// [optionsInlineSourceMapSourcemap.js]
var a = 10;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcFNvdXJjZW1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIm9wdGlvbnNJbmxpbmVTb3VyY2VNYXBTb3VyY2VtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFDIn0=

View File

@@ -0,0 +1,33 @@
===================================================================
JsFile: optionsInlineSourceMapSourcemap.js
mapUrl: optionsInlineSourceMapSourcemap.js.map
sourceRoot:
sources: optionsInlineSourceMapSourcemap.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/compiler/optionsInlineSourceMapSourcemap.js
sourceFile:optionsInlineSourceMapSourcemap.ts
-------------------------------------------------------------------
>>>var a = 10;
1 >
2 >^^^^
3 > ^
4 > ^^^
5 > ^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >var
3 > a
4 > =
5 > 10
6 > ;
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
---
>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcFNvdXJjZW1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIm9wdGlvbnNJbmxpbmVTb3VyY2VNYXBTb3VyY2VtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFDIn0=

View File

@@ -0,0 +1,7 @@
//// [optionsSourcemapInlineSources.ts]
var a = 10;
//// [optionsSourcemapInlineSources.js]
var a = 10;
//# sourceMappingURL=optionsSourcemapInlineSources.js.map

View File

@@ -0,0 +1,2 @@
//// [optionsSourcemapInlineSources.js.map]
{"version":3,"file":"optionsSourcemapInlineSources.js","sourceRoot":"","sources":["optionsSourcemapInlineSources.ts"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,EAAE,CAAC","sourcesContent":["\nvar a = 10;"]}

View File

@@ -0,0 +1,34 @@
===================================================================
JsFile: optionsSourcemapInlineSources.js
mapUrl: optionsSourcemapInlineSources.js.map
sourceRoot:
sources: optionsSourcemapInlineSources.ts
sourcesContent: ["\nvar a = 10;"]
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/compiler/optionsSourcemapInlineSources.js
sourceFile:optionsSourcemapInlineSources.ts
-------------------------------------------------------------------
>>>var a = 10;
1 >
2 >^^^^
3 > ^
4 > ^^^
5 > ^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >var
3 > a
4 > =
5 > 10
6 > ;
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
---
>>>//# sourceMappingURL=optionsSourcemapInlineSources.js.map

View File

@@ -0,0 +1,5 @@
=== tests/cases/compiler/optionsSourcemapInlineSources.ts ===
var a = 10;
>a : Symbol(a, Decl(optionsSourcemapInlineSources.ts, 1, 3))

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/optionsSourcemapInlineSources.ts ===
var a = 10;
>a : number
>10 : number

View File

@@ -0,0 +1,7 @@
//// [optionsSourcemapInlineSourcesMapRoot.ts]
var a = 10;
//// [optionsSourcemapInlineSourcesMapRoot.js]
var a = 10;
//# sourceMappingURL=local/optionsSourcemapInlineSourcesMapRoot.js.map

View File

@@ -0,0 +1,2 @@
//// [optionsSourcemapInlineSourcesMapRoot.js.map]
{"version":3,"file":"optionsSourcemapInlineSourcesMapRoot.js","sourceRoot":"","sources":["../optionsSourcemapInlineSourcesMapRoot.ts"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,EAAE,CAAC","sourcesContent":["\nvar a = 10;"]}

View File

@@ -0,0 +1,34 @@
===================================================================
JsFile: optionsSourcemapInlineSourcesMapRoot.js
mapUrl: local/optionsSourcemapInlineSourcesMapRoot.js.map
sourceRoot:
sources: ../optionsSourcemapInlineSourcesMapRoot.ts
sourcesContent: ["\nvar a = 10;"]
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/compiler/optionsSourcemapInlineSourcesMapRoot.js
sourceFile:../optionsSourcemapInlineSourcesMapRoot.ts
-------------------------------------------------------------------
>>>var a = 10;
1 >
2 >^^^^
3 > ^
4 > ^^^
5 > ^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >var
3 > a
4 > =
5 > 10
6 > ;
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
---
>>>//# sourceMappingURL=local/optionsSourcemapInlineSourcesMapRoot.js.map

View File

@@ -0,0 +1,5 @@
=== tests/cases/compiler/optionsSourcemapInlineSourcesMapRoot.ts ===
var a = 10;
>a : Symbol(a, Decl(optionsSourcemapInlineSourcesMapRoot.ts, 1, 3))

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/optionsSourcemapInlineSourcesMapRoot.ts ===
var a = 10;
>a : number
>10 : number

View File

@@ -0,0 +1,7 @@
error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSources'.
!!! error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSources'.
==== tests/cases/compiler/optionsSourcemapInlineSourcesSourceRoot.ts (0 errors) ====
var a = 10;

View File

@@ -0,0 +1,7 @@
//// [optionsSourcemapInlineSourcesSourceRoot.ts]
var a = 10;
//// [optionsSourcemapInlineSourcesSourceRoot.js]
var a = 10;
//# sourceMappingURL=optionsSourcemapInlineSourcesSourceRoot.js.map

View File

@@ -0,0 +1,2 @@
//// [optionsSourcemapInlineSourcesSourceRoot.js.map]
{"version":3,"file":"optionsSourcemapInlineSourcesSourceRoot.js","sourceRoot":"local/","sources":["optionsSourcemapInlineSourcesSourceRoot.ts"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,EAAE,CAAC","sourcesContent":["\nvar a = 10;"]}

View File

@@ -0,0 +1,34 @@
===================================================================
JsFile: optionsSourcemapInlineSourcesSourceRoot.js
mapUrl: optionsSourcemapInlineSourcesSourceRoot.js.map
sourceRoot: local/
sources: optionsSourcemapInlineSourcesSourceRoot.ts
sourcesContent: ["\nvar a = 10;"]
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/compiler/optionsSourcemapInlineSourcesSourceRoot.js
sourceFile:optionsSourcemapInlineSourcesSourceRoot.ts
-------------------------------------------------------------------
>>>var a = 10;
1 >
2 >^^^^
3 > ^
4 > ^^^
5 > ^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >var
3 > a
4 > =
5 > 10
6 > ;
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
---
>>>//# sourceMappingURL=optionsSourcemapInlineSourcesSourceRoot.js.map

View File

@@ -0,0 +1,10 @@
//// [sourceMapValidationLambdaSpanningMultipleLines.ts]
((item: string) =>
item
)
//// [sourceMapValidationLambdaSpanningMultipleLines.js]
(function (item) {
return item;
});
//# sourceMappingURL=sourceMapValidationLambdaSpanningMultipleLines.js.map

View File

@@ -0,0 +1,2 @@
//// [sourceMapValidationLambdaSpanningMultipleLines.js.map]
{"version":3,"file":"sourceMapValidationLambdaSpanningMultipleLines.js","sourceRoot":"","sources":["sourceMapValidationLambdaSpanningMultipleLines.ts"],"names":[],"mappings":"AAAA,CAAC,UAAC,IAAY;IACV,OAAA,IAAI;AAAJ,CAAI,CACP,CAAA"}

View File

@@ -0,0 +1,54 @@
===================================================================
JsFile: sourceMapValidationLambdaSpanningMultipleLines.js
mapUrl: sourceMapValidationLambdaSpanningMultipleLines.js.map
sourceRoot:
sources: sourceMapValidationLambdaSpanningMultipleLines.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/compiler/sourceMapValidationLambdaSpanningMultipleLines.js
sourceFile:sourceMapValidationLambdaSpanningMultipleLines.ts
-------------------------------------------------------------------
>>>(function (item) {
1 >
2 >^
3 > ^^^^^^^^^^
4 > ^^^^
5 > ^^->
1 >
2 >(
3 > (
4 > item: string
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 2) Source(1, 2) + SourceIndex(0)
3 >Emitted(1, 12) Source(1, 3) + SourceIndex(0)
4 >Emitted(1, 16) Source(1, 15) + SourceIndex(0)
---
>>> return item;
1->^^^^
2 > ^^^^^^^
3 > ^^^^
1->) =>
>
2 >
3 > item
1->Emitted(2, 5) Source(2, 5) + SourceIndex(0)
2 >Emitted(2, 12) Source(2, 5) + SourceIndex(0)
3 >Emitted(2, 16) Source(2, 9) + SourceIndex(0)
---
>>>});
1 >
2 >^
3 > ^
4 > ^
5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
2 >item
3 >
> )
4 >
1 >Emitted(3, 1) Source(2, 5) + SourceIndex(0)
2 >Emitted(3, 2) Source(2, 9) + SourceIndex(0)
3 >Emitted(3, 3) Source(3, 2) + SourceIndex(0)
4 >Emitted(3, 4) Source(3, 2) + SourceIndex(0)
---
>>>//# sourceMappingURL=sourceMapValidationLambdaSpanningMultipleLines.js.map

View File

@@ -0,0 +1,8 @@
=== tests/cases/compiler/sourceMapValidationLambdaSpanningMultipleLines.ts ===
((item: string) =>
>item : Symbol(item, Decl(sourceMapValidationLambdaSpanningMultipleLines.ts, 0, 2))
item
>item : Symbol(item, Decl(sourceMapValidationLambdaSpanningMultipleLines.ts, 0, 2))
)

View File

@@ -0,0 +1,10 @@
=== tests/cases/compiler/sourceMapValidationLambdaSpanningMultipleLines.ts ===
((item: string) =>
>((item: string) => item) : (item: string) => string
>(item: string) => item : (item: string) => string
>item : string
item
>item : string
)

View File

@@ -20,6 +20,6 @@ declare var Foo, React;
//// [app.js]
var mod_1 = require('mod');
// Should see mod_1['default'] in emit here
React.createElement(Foo, {"handler": mod_1["default"]});
React.createElement(Foo, {handler: mod_1["default"]});
// Should see mod_1['default'] in emit here
React.createElement(Foo, React.__spread({}, mod_1["default"]));

View File

@@ -0,0 +1,50 @@
tests/cases/conformance/jsx/tsxReactEmit7.tsx(9,10): error TS2304: Cannot find name 'React'.
tests/cases/conformance/jsx/tsxReactEmit7.tsx(10,10): error TS2304: Cannot find name 'React'.
tests/cases/conformance/jsx/tsxReactEmit7.tsx(11,10): error TS2304: Cannot find name 'React'.
tests/cases/conformance/jsx/tsxReactEmit7.tsx(12,10): error TS2304: Cannot find name 'React'.
tests/cases/conformance/jsx/tsxReactEmit7.tsx(15,10): error TS2304: Cannot find name 'React'.
tests/cases/conformance/jsx/tsxReactEmit7.tsx(16,10): error TS2304: Cannot find name 'React'.
tests/cases/conformance/jsx/tsxReactEmit7.tsx(17,10): error TS2304: Cannot find name 'React'.
tests/cases/conformance/jsx/tsxReactEmit7.tsx(18,10): error TS2304: Cannot find name 'React'.
tests/cases/conformance/jsx/tsxReactEmit7.tsx(19,10): error TS2304: Cannot find name 'React'.
==== tests/cases/conformance/jsx/tsxReactEmit7.tsx (9 errors) ====
declare module JSX {
interface Element { }
interface IntrinsicElements {
[s: string]: any;
}
}
var m = <div x-y="val"></div>;
~~~
!!! error TS2304: Cannot find name 'React'.
var n = <div xx-y="val"></div>;
~~~
!!! error TS2304: Cannot find name 'React'.
var o = <div x-yy="val"></div>;
~~~
!!! error TS2304: Cannot find name 'React'.
var p = <div xx-yy="val"></div>;
~~~
!!! error TS2304: Cannot find name 'React'.
// Investigation
var a = <div x="val"></div>;
~~~
!!! error TS2304: Cannot find name 'React'.
var b = <div xx="val"></div>;
~~~
!!! error TS2304: Cannot find name 'React'.
var c = <div xxx="val"></div>;
~~~
!!! error TS2304: Cannot find name 'React'.
var d = <div xxxx="val"></div>;
~~~
!!! error TS2304: Cannot find name 'React'.
var e = <div xxxxx="val"></div>;
~~~
!!! error TS2304: Cannot find name 'React'.

View File

@@ -0,0 +1,33 @@
//// [tsxReactEmit7.tsx]
declare module JSX {
interface Element { }
interface IntrinsicElements {
[s: string]: any;
}
}
var m = <div x-y="val"></div>;
var n = <div xx-y="val"></div>;
var o = <div x-yy="val"></div>;
var p = <div xx-yy="val"></div>;
// Investigation
var a = <div x="val"></div>;
var b = <div xx="val"></div>;
var c = <div xxx="val"></div>;
var d = <div xxxx="val"></div>;
var e = <div xxxxx="val"></div>;
//// [tsxReactEmit7.js]
var m = React.createElement("div", {"x-y": "val"});
var n = React.createElement("div", {"xx-y": "val"});
var o = React.createElement("div", {"x-yy": "val"});
var p = React.createElement("div", {"xx-yy": "val"});
// Investigation
var a = React.createElement("div", {x: "val"});
var b = React.createElement("div", {xx: "val"});
var c = React.createElement("div", {xxx: "val"});
var d = React.createElement("div", {xxxx: "val"});
var e = React.createElement("div", {xxxxx: "val"});

View File

@@ -0,0 +1,357 @@
//// [typeGuardTypeOfUndefined.ts]
// undefined type guard adds no new type information
function test1(a: any) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test2(a: any) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test3(a: any) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test4(a: any) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
function test5(a: boolean | void) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test6(a: boolean | void) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test7(a: boolean | void) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test8(a: boolean | void) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
function test9(a: boolean | number) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test10(a: boolean | number) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test11(a: boolean | number) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test12(a: boolean | number) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
function test13(a: boolean | number | void) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test14(a: boolean | number | void) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test15(a: boolean | number | void) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test16(a: boolean | number | void) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
//// [typeGuardTypeOfUndefined.js]
// undefined type guard adds no new type information
function test1(a) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test2(a) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test3(a) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test4(a) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
function test5(a) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test6(a) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test7(a) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test8(a) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
function test9(a) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test10(a) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test11(a) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test12(a) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
function test13(a) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test14(a) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test15(a) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test16(a) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}

View File

@@ -0,0 +1,330 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardTypeOfUndefined.ts ===
// undefined type guard adds no new type information
function test1(a: any) {
>test1 : Symbol(test1, Decl(typeGuardTypeOfUndefined.ts, 0, 0))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 1, 15))
if (typeof a !== "undefined") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 1, 15))
if (typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 1, 15))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 1, 15))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 1, 15))
}
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 1, 15))
}
}
function test2(a: any) {
>test2 : Symbol(test2, Decl(typeGuardTypeOfUndefined.ts, 13, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 15, 15))
if (typeof a === "undefined") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 15, 15))
if (typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 15, 15))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 15, 15))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 15, 15))
}
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 15, 15))
}
}
function test3(a: any) {
>test3 : Symbol(test3, Decl(typeGuardTypeOfUndefined.ts, 27, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 29, 15))
if (typeof a === "undefined" || typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 29, 15))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 29, 15))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 29, 15))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 29, 15))
}
}
function test4(a: any) {
>test4 : Symbol(test4, Decl(typeGuardTypeOfUndefined.ts, 36, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 38, 15))
if (typeof a !== "undefined" && typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 38, 15))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 38, 15))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 38, 15))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 38, 15))
}
}
function test5(a: boolean | void) {
>test5 : Symbol(test5, Decl(typeGuardTypeOfUndefined.ts, 45, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 47, 15))
if (typeof a !== "undefined") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 47, 15))
if (typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 47, 15))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 47, 15))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 47, 15))
}
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 47, 15))
}
}
function test6(a: boolean | void) {
>test6 : Symbol(test6, Decl(typeGuardTypeOfUndefined.ts, 59, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 61, 15))
if (typeof a === "undefined") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 61, 15))
if (typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 61, 15))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 61, 15))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 61, 15))
}
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 61, 15))
}
}
function test7(a: boolean | void) {
>test7 : Symbol(test7, Decl(typeGuardTypeOfUndefined.ts, 73, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 75, 15))
if (typeof a === "undefined" || typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 75, 15))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 75, 15))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 75, 15))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 75, 15))
}
}
function test8(a: boolean | void) {
>test8 : Symbol(test8, Decl(typeGuardTypeOfUndefined.ts, 82, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 84, 15))
if (typeof a !== "undefined" && typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 84, 15))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 84, 15))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 84, 15))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 84, 15))
}
}
function test9(a: boolean | number) {
>test9 : Symbol(test9, Decl(typeGuardTypeOfUndefined.ts, 91, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 93, 15))
if (typeof a !== "undefined") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 93, 15))
if (typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 93, 15))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 93, 15))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 93, 15))
}
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 93, 15))
}
}
function test10(a: boolean | number) {
>test10 : Symbol(test10, Decl(typeGuardTypeOfUndefined.ts, 105, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 107, 16))
if (typeof a === "undefined") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 107, 16))
if (typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 107, 16))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 107, 16))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 107, 16))
}
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 107, 16))
}
}
function test11(a: boolean | number) {
>test11 : Symbol(test11, Decl(typeGuardTypeOfUndefined.ts, 119, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 121, 16))
if (typeof a === "undefined" || typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 121, 16))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 121, 16))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 121, 16))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 121, 16))
}
}
function test12(a: boolean | number) {
>test12 : Symbol(test12, Decl(typeGuardTypeOfUndefined.ts, 128, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 130, 16))
if (typeof a !== "undefined" && typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 130, 16))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 130, 16))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 130, 16))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 130, 16))
}
}
function test13(a: boolean | number | void) {
>test13 : Symbol(test13, Decl(typeGuardTypeOfUndefined.ts, 137, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 139, 16))
if (typeof a !== "undefined") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 139, 16))
if (typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 139, 16))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 139, 16))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 139, 16))
}
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 139, 16))
}
}
function test14(a: boolean | number | void) {
>test14 : Symbol(test14, Decl(typeGuardTypeOfUndefined.ts, 151, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 153, 16))
if (typeof a === "undefined") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 153, 16))
if (typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 153, 16))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 153, 16))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 153, 16))
}
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 153, 16))
}
}
function test15(a: boolean | number | void) {
>test15 : Symbol(test15, Decl(typeGuardTypeOfUndefined.ts, 165, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 167, 16))
if (typeof a === "undefined" || typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 167, 16))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 167, 16))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 167, 16))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 167, 16))
}
}
function test16(a: boolean | number | void) {
>test16 : Symbol(test16, Decl(typeGuardTypeOfUndefined.ts, 174, 1))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 176, 16))
if (typeof a !== "undefined" && typeof a === "boolean") {
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 176, 16))
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 176, 16))
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 176, 16))
}
else {
a;
>a : Symbol(a, Decl(typeGuardTypeOfUndefined.ts, 176, 16))
}
}

View File

@@ -0,0 +1,434 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardTypeOfUndefined.ts ===
// undefined type guard adds no new type information
function test1(a: any) {
>test1 : (a: any) => void
>a : any
if (typeof a !== "undefined") {
>typeof a !== "undefined" : boolean
>typeof a : string
>a : any
>"undefined" : string
if (typeof a === "boolean") {
>typeof a === "boolean" : boolean
>typeof a : string
>a : any
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : any
}
}
else {
a;
>a : any
}
}
function test2(a: any) {
>test2 : (a: any) => void
>a : any
if (typeof a === "undefined") {
>typeof a === "undefined" : boolean
>typeof a : string
>a : any
>"undefined" : string
if (typeof a === "boolean") {
>typeof a === "boolean" : boolean
>typeof a : string
>a : any
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : any
}
}
else {
a;
>a : any
}
}
function test3(a: any) {
>test3 : (a: any) => void
>a : any
if (typeof a === "undefined" || typeof a === "boolean") {
>typeof a === "undefined" || typeof a === "boolean" : boolean
>typeof a === "undefined" : boolean
>typeof a : string
>a : any
>"undefined" : string
>typeof a === "boolean" : boolean
>typeof a : string
>a : any
>"boolean" : string
a;
>a : any
}
else {
a;
>a : any
}
}
function test4(a: any) {
>test4 : (a: any) => void
>a : any
if (typeof a !== "undefined" && typeof a === "boolean") {
>typeof a !== "undefined" && typeof a === "boolean" : boolean
>typeof a !== "undefined" : boolean
>typeof a : string
>a : any
>"undefined" : string
>typeof a === "boolean" : boolean
>typeof a : string
>a : any
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : any
}
}
function test5(a: boolean | void) {
>test5 : (a: boolean | void) => void
>a : boolean | void
if (typeof a !== "undefined") {
>typeof a !== "undefined" : boolean
>typeof a : string
>a : boolean | void
>"undefined" : string
if (typeof a === "boolean") {
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | void
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : void
}
}
else {
a;
>a : boolean | void
}
}
function test6(a: boolean | void) {
>test6 : (a: boolean | void) => void
>a : boolean | void
if (typeof a === "undefined") {
>typeof a === "undefined" : boolean
>typeof a : string
>a : boolean | void
>"undefined" : string
if (typeof a === "boolean") {
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | void
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : void
}
}
else {
a;
>a : boolean | void
}
}
function test7(a: boolean | void) {
>test7 : (a: boolean | void) => void
>a : boolean | void
if (typeof a === "undefined" || typeof a === "boolean") {
>typeof a === "undefined" || typeof a === "boolean" : boolean
>typeof a === "undefined" : boolean
>typeof a : string
>a : boolean | void
>"undefined" : string
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | void
>"boolean" : string
a;
>a : boolean | void
}
else {
a;
>a : void
}
}
function test8(a: boolean | void) {
>test8 : (a: boolean | void) => void
>a : boolean | void
if (typeof a !== "undefined" && typeof a === "boolean") {
>typeof a !== "undefined" && typeof a === "boolean" : boolean
>typeof a !== "undefined" : boolean
>typeof a : string
>a : boolean | void
>"undefined" : string
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | void
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : boolean | void
}
}
function test9(a: boolean | number) {
>test9 : (a: boolean | number) => void
>a : boolean | number
if (typeof a !== "undefined") {
>typeof a !== "undefined" : boolean
>typeof a : string
>a : boolean | number
>"undefined" : string
if (typeof a === "boolean") {
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | number
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : number
}
}
else {
a;
>a : boolean | number
}
}
function test10(a: boolean | number) {
>test10 : (a: boolean | number) => void
>a : boolean | number
if (typeof a === "undefined") {
>typeof a === "undefined" : boolean
>typeof a : string
>a : boolean | number
>"undefined" : string
if (typeof a === "boolean") {
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | number
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : number
}
}
else {
a;
>a : boolean | number
}
}
function test11(a: boolean | number) {
>test11 : (a: boolean | number) => void
>a : boolean | number
if (typeof a === "undefined" || typeof a === "boolean") {
>typeof a === "undefined" || typeof a === "boolean" : boolean
>typeof a === "undefined" : boolean
>typeof a : string
>a : boolean | number
>"undefined" : string
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | number
>"boolean" : string
a;
>a : boolean | number
}
else {
a;
>a : number
}
}
function test12(a: boolean | number) {
>test12 : (a: boolean | number) => void
>a : boolean | number
if (typeof a !== "undefined" && typeof a === "boolean") {
>typeof a !== "undefined" && typeof a === "boolean" : boolean
>typeof a !== "undefined" : boolean
>typeof a : string
>a : boolean | number
>"undefined" : string
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | number
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : boolean | number
}
}
function test13(a: boolean | number | void) {
>test13 : (a: boolean | number | void) => void
>a : boolean | number | void
if (typeof a !== "undefined") {
>typeof a !== "undefined" : boolean
>typeof a : string
>a : boolean | number | void
>"undefined" : string
if (typeof a === "boolean") {
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | number | void
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : number | void
}
}
else {
a;
>a : boolean | number | void
}
}
function test14(a: boolean | number | void) {
>test14 : (a: boolean | number | void) => void
>a : boolean | number | void
if (typeof a === "undefined") {
>typeof a === "undefined" : boolean
>typeof a : string
>a : boolean | number | void
>"undefined" : string
if (typeof a === "boolean") {
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | number | void
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : number | void
}
}
else {
a;
>a : boolean | number | void
}
}
function test15(a: boolean | number | void) {
>test15 : (a: boolean | number | void) => void
>a : boolean | number | void
if (typeof a === "undefined" || typeof a === "boolean") {
>typeof a === "undefined" || typeof a === "boolean" : boolean
>typeof a === "undefined" : boolean
>typeof a : string
>a : boolean | number | void
>"undefined" : string
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | number | void
>"boolean" : string
a;
>a : boolean | number | void
}
else {
a;
>a : number | void
}
}
function test16(a: boolean | number | void) {
>test16 : (a: boolean | number | void) => void
>a : boolean | number | void
if (typeof a !== "undefined" && typeof a === "boolean") {
>typeof a !== "undefined" && typeof a === "boolean" : boolean
>typeof a !== "undefined" : boolean
>typeof a : string
>a : boolean | number | void
>"undefined" : string
>typeof a === "boolean" : boolean
>typeof a : string
>a : boolean | number | void
>"boolean" : string
a;
>a : boolean
}
else {
a;
>a : boolean | number | void
}
}

View File

@@ -1,2 +1,23 @@
// @Filename: ambientClassDeclarationExtends_singleFile.ts
declare class A { }
declare class B extends A { }
declare class C {
public foo;
}
namespace D { var x; }
declare class D extends C { }
var d: C = new D();
// @Filename: ambientClassDeclarationExtends_file1.ts
declare class E {
public bar;
}
namespace F { var y; }
// @Filename: ambientClassDeclarationExtends_file2.ts
declare class F extends E { }
var f: E = new F();

View File

@@ -0,0 +1,11 @@
declare function use(a: any): void;
class A {
doIt(x: Array<string>): void {
x.forEach((v) => {
switch(v) {
case "test": use(this);
}
});
}
}

View File

@@ -0,0 +1,15 @@
class A {
f() {}
static m1 (a: string): void;
m1 (a: number): void;
m1 (a: any): void {
}
}
class B {
f() {}
m1 (a: string): void;
static m1 (a: number): void;
m1 (a: any): void {
}
}

View File

@@ -0,0 +1,8 @@
class A {
m1: string;
f() {}
m1 (a: string): void;
m1 (a: number): void;
m1 (a: any): void {
}
}

View File

@@ -0,0 +1,5 @@
var f = 10;
export function f();
export function f() {
}

View File

@@ -0,0 +1,4 @@
// @mapRoot: local
// @inlineSourceMap: true
var a = 10;

View File

@@ -0,0 +1,4 @@
// @sourceRoot: local
// @inlineSourceMap: true
var a = 10;

View File

@@ -0,0 +1,4 @@
// @sourcemap: true
// @inlineSourceMap: true
var a = 10;

View File

@@ -0,0 +1,4 @@
// @sourcemap: true
// @inlineSources: true
var a = 10;

View File

@@ -0,0 +1,5 @@
// @sourcemap: true
// @inlineSources: true
// @mapRoot: local
var a = 10;

View File

@@ -0,0 +1,5 @@
// @sourcemap: true
// @inlineSources: true
// @sourceRoot: local
var a = 10;

View File

@@ -0,0 +1,4 @@
// @sourcemap: true
((item: string) =>
item
)

View File

@@ -0,0 +1,184 @@
// undefined type guard adds no new type information
function test1(a: any) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test2(a: any) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test3(a: any) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test4(a: any) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
function test5(a: boolean | void) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test6(a: boolean | void) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test7(a: boolean | void) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test8(a: boolean | void) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
function test9(a: boolean | number) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test10(a: boolean | number) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test11(a: boolean | number) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test12(a: boolean | number) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}
function test13(a: boolean | number | void) {
if (typeof a !== "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test14(a: boolean | number | void) {
if (typeof a === "undefined") {
if (typeof a === "boolean") {
a;
}
else {
a;
}
}
else {
a;
}
}
function test15(a: boolean | number | void) {
if (typeof a === "undefined" || typeof a === "boolean") {
a;
}
else {
a;
}
}
function test16(a: boolean | number | void) {
if (typeof a !== "undefined" && typeof a === "boolean") {
a;
}
else {
a;
}
}

View File

@@ -0,0 +1,22 @@
//@jsx: react
//@module: commonjs
//@filename: file.tsx
declare module JSX {
interface Element { }
interface IntrinsicElements {
[s: string]: any;
}
}
var m = <div x-y="val"></div>;
var n = <div xx-y="val"></div>;
var o = <div x-yy="val"></div>;
var p = <div xx-yy="val"></div>;
// Investigation
var a = <div x="val"></div>;
var b = <div xx="val"></div>;
var c = <div xxx="val"></div>;
var d = <div xxxx="val"></div>;
var e = <div xxxxx="val"></div>;

View File

@@ -3,16 +3,16 @@
//// var f4 = <T>(x: T/**/ ) => {
//// }
fs.goTo.marker();
goTo.marker();
// Replace the "T" type with the non-existent type 'V'.
fs.edit.backspace(1);
fs.edit.insert("A");
edit.backspace(1);
edit.insert("A");
// Bring up completion to force a pull resolve. This will end up resolving several symbols and
// producing unreported diagnostics (i.e. that 'V' wasn't found).
fs.verify.completionListContains("T");
fs.verify.completionEntryDetailIs("T", "(type parameter) T in <T>(x: any): void");
verify.completionListContains("T");
verify.completionEntryDetailIs("T", "(type parameter) T in <T>(x: any): void");
// There should now be a single error.
fs.verify.numberOfErrorsInCurrentFile(1);
verify.numberOfErrorsInCurrentFile(1);

View File

@@ -24,10 +24,7 @@
// @Module: Node
// @Target: ES5
// In the imperative section, you can write any valid TypeScript code. If
// you need help finding a something in Intellisense, you can
// type 'fs.' as an alternate way of accessing the top-level objects
// (e.g. 'fs.goTo.eof();')
// In the imperative section, you can write any valid TypeScript code.
//---------------------------------------
// For API editors:
@@ -45,52 +42,32 @@
//
// TODO: figure out a better solution to the API exposure problem.
// /// <reference path="../../../built/local/typescriptServices.d.ts"/>
// /// <reference path="../../../src/harness/fourslash.ts"/>
declare var FourSlash;
module ts {
export interface SymbolDisplayPart {
declare module ts {
interface SymbolDisplayPart {
text: string;
kind: string;
}
enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
}
}
//---------------------------------------------
// Return code used by getEmitOutput function to indicate status of the function
// It is a duplicate of the one in types.ts to expose it to testcases in fourslash
enum EmitReturnStatus {
Succeeded = 0, // All outputs generated if requested (.js, .map, .d.ts), no errors reported
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, or compiler options errors, nothing generated
JSGeneratedWithSemanticErrors = 2, // .js and .map generated with semantic errors
DeclarationGenerationSkipped = 3, // .d.ts generation skipped because of semantic errors or declaration emitter specific errors; Output .js with semantic errors
EmitErrorsEncountered = 4 // Emitter errors occurred during emitting process
}
// This is a duplicate of the indentstyle in services.ts to expose it to testcases in fourslash
enum IndentStyle {
None,
Block,
Smart,
}
module FourSlashInterface {
export interface Marker {
declare namespace FourSlashInterface {
interface Marker {
fileName: string;
position: number;
data?: any;
}
export interface EditorOptions {
interface EditorOptions {
IndentSize: number;
TabSize: number;
NewLineCharacter: string;
ConvertTabsToSpaces: boolean;
}
export interface FormatCodeOptions extends EditorOptions {
interface FormatCodeOptions extends EditorOptions {
InsertSpaceAfterCommaDelimiter: boolean;
InsertSpaceAfterSemicolonInForStatements: boolean;
InsertSpaceBeforeAndAfterBinaryOperators: boolean;
@@ -100,646 +77,266 @@ module FourSlashInterface {
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number| string;
[s: string]: boolean | number | string;
}
export interface Range {
interface Range {
fileName: string;
start: number;
end: number;
marker?: Marker;
}
export interface TextSpan {
interface TextSpan {
start: number;
end: number;
}
export class test_ {
public markers(): Marker[] {
return FourSlash.currentTestState.getMarkers();
}
public marker(name?: string): Marker {
return FourSlash.currentTestState.getMarkerByName(name);
}
public ranges(): Range[] {
return FourSlash.currentTestState.getRanges();
}
public markerByName(s: string): Marker {
return FourSlash.currentTestState.getMarkerByName(s);
}
class test_ {
markers(): Marker[];
marker(name?: string): Marker;
ranges(): Range[];
markerByName(s: string): Marker;
}
export class goTo {
// Moves the caret to the specified marker,
// or the anonymous marker ('/**/') if no name
// is given
public marker(name?: string) {
FourSlash.currentTestState.goToMarker(name);
}
public bof() {
FourSlash.currentTestState.goToBOF();
}
public eof() {
FourSlash.currentTestState.goToEOF();
}
public definition(definitionIndex: number = 0) {
FourSlash.currentTestState.goToDefinition(definitionIndex);
}
public type(definitionIndex: number = 0) {
FourSlash.currentTestState.goToTypeDefinition(definitionIndex);
}
public position(position: number, fileIndex?: number);
public position(position: number, fileName?: string);
public position(position: number, fileNameOrIndex?: any) {
if (fileNameOrIndex !== undefined) {
this.file(fileNameOrIndex);
}
FourSlash.currentTestState.goToPosition(position);
}
// Opens a file, given either its index as it
// appears in the test source, or its filename
// as specified in the test metadata
public file(index: number);
public file(name: string);
public file(indexOrName: any) {
FourSlash.currentTestState.openFile(indexOrName);
}
class goTo {
marker(name?: string): void;
bof(): void;
eof(): void;
definition(definitionIndex?: number): void;
type(definitionIndex?: number): void;
position(position: number, fileIndex?: number): any;
position(position: number, fileName?: string): any;
file(index: number, content?: string): any;
file(name: string, content?: string): any;
}
export class verifyNegatable {
public not: verifyNegatable;
constructor(private negative = false) {
if (!negative) {
this.not = new verifyNegatable(true);
}
}
// Verifies the member list contains the specified symbol. The
// member list is brought up if necessary
public memberListContains(symbol: string, text?: string, documenation?: string, kind?: string) {
if (this.negative) {
FourSlash.currentTestState.verifyMemberListDoesNotContain(symbol);
} else {
FourSlash.currentTestState.verifyMemberListContains(symbol, text, documenation, kind);
}
}
public memberListCount(expectedCount: number) {
FourSlash.currentTestState.verifyMemberListCount(expectedCount, this.negative);
}
// Verifies the completion list contains the specified symbol. The
// completion list is brought up if necessary
public completionListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
if (this.negative) {
FourSlash.currentTestState.verifyCompletionListDoesNotContain(symbol, text, documentation, kind);
} else {
FourSlash.currentTestState.verifyCompletionListContains(symbol, text, documentation, kind);
}
}
// Verifies the completion list items count to be greater than the specified amount. The
// completion list is brought up if necessary
public completionListItemsCountIsGreaterThan(count: number) {
FourSlash.currentTestState.verifyCompletionListItemsCountIsGreaterThan(count, this.negative);
}
public completionListIsEmpty() {
FourSlash.currentTestState.verifyCompletionListIsEmpty(this.negative);
}
public completionListAllowsNewIdentifier() {
FourSlash.currentTestState.verifyCompletionListAllowsNewIdentifier(this.negative);
}
public memberListIsEmpty() {
FourSlash.currentTestState.verifyMemberListIsEmpty(this.negative);
}
public referencesCountIs(count: number) {
FourSlash.currentTestState.verifyReferencesCountIs(count, /*localFilesOnly*/ false);
}
public referencesAtPositionContains(range: Range, isWriteAccess?: boolean) {
FourSlash.currentTestState.verifyReferencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess);
}
public signatureHelpPresent() {
FourSlash.currentTestState.verifySignatureHelpPresent(!this.negative);
}
public errorExistsBetweenMarkers(startMarker: string, endMarker: string) {
FourSlash.currentTestState.verifyErrorExistsBetweenMarkers(startMarker, endMarker, !this.negative);
}
public errorExistsAfterMarker(markerName = "") {
FourSlash.currentTestState.verifyErrorExistsAfterMarker(markerName, !this.negative, true);
}
public errorExistsBeforeMarker(markerName = "") {
FourSlash.currentTestState.verifyErrorExistsAfterMarker(markerName, !this.negative, false);
}
public quickInfoIs(expectedText?: string, expectedDocumentation?: string) {
FourSlash.currentTestState.verifyQuickInfoString(this.negative, expectedText, expectedDocumentation);
}
public quickInfoExists() {
FourSlash.currentTestState.verifyQuickInfoExists(this.negative);
}
public definitionCountIs(expectedCount: number) {
FourSlash.currentTestState.verifyDefinitionsCount(this.negative, expectedCount);
}
public typeDefinitionCountIs(expectedCount: number) {
FourSlash.currentTestState.verifyTypeDefinitionsCount(this.negative, expectedCount);
}
public definitionLocationExists() {
FourSlash.currentTestState.verifyDefinitionLocationExists(this.negative);
}
public verifyDefinitionsName(name: string, containerName: string) {
FourSlash.currentTestState.verifyDefinitionsName(this.negative, name, containerName);
}
class verifyNegatable {
private negative;
not: verifyNegatable;
constructor(negative?: boolean);
memberListContains(symbol: string, text?: string, documenation?: string, kind?: string): void;
memberListCount(expectedCount: number): void;
completionListContains(symbol: string, text?: string, documentation?: string, kind?: string): void;
completionListItemsCountIsGreaterThan(count: number): void;
completionListIsEmpty(): void;
completionListAllowsNewIdentifier(): void;
memberListIsEmpty(): void;
referencesCountIs(count: number): void;
referencesAtPositionContains(range: Range, isWriteAccess?: boolean): void;
signatureHelpPresent(): void;
errorExistsBetweenMarkers(startMarker: string, endMarker: string): void;
errorExistsAfterMarker(markerName?: string): void;
errorExistsBeforeMarker(markerName?: string): void;
quickInfoIs(expectedText?: string, expectedDocumentation?: string): void;
quickInfoExists(): void;
definitionCountIs(expectedCount: number): void;
typeDefinitionCountIs(expectedCount: number): void;
definitionLocationExists(): void;
verifyDefinitionsName(name: string, containerName: string): void;
}
export class verify extends verifyNegatable {
public caretAtMarker(markerName?: string) {
FourSlash.currentTestState.verifyCaretAtMarker(markerName);
}
public indentationIs(numberOfSpaces: number) {
FourSlash.currentTestState.verifyIndentationAtCurrentPosition(numberOfSpaces);
}
public indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle = IndentStyle.Smart) {
FourSlash.currentTestState.verifyIndentationAtPosition(fileName, position, numberOfSpaces, indentStyle);
}
public textAtCaretIs(text: string) {
FourSlash.currentTestState.verifyTextAtCaretIs(text);
}
class verify extends verifyNegatable {
caretAtMarker(markerName?: string): void;
indentationIs(numberOfSpaces: number): void;
indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: IndentStyle): void;
textAtCaretIs(text: string): void;
/**
* Compiles the current file and evaluates 'expr' in a context containing
* the emitted output, then compares (using ===) the result of that expression
* to 'value'. Do not use this function with external modules as it is not supported.
*/
public eval(expr: string, value: any) {
FourSlash.currentTestState.verifyEval(expr, value);
}
public currentLineContentIs(text: string) {
FourSlash.currentTestState.verifyCurrentLineContent(text);
}
public currentFileContentIs(text: string) {
FourSlash.currentTestState.verifyCurrentFileContent(text);
}
public verifyGetEmitOutputForCurrentFile(expected: string): void {
FourSlash.currentTestState.verifyGetEmitOutputForCurrentFile(expected);
}
public currentParameterHelpArgumentNameIs(name: string) {
FourSlash.currentTestState.verifyCurrentParameterHelpName(name);
}
public currentParameterSpanIs(parameter: string) {
FourSlash.currentTestState.verifyCurrentParameterSpanIs(parameter);
}
public currentParameterHelpArgumentDocCommentIs(docComment: string) {
FourSlash.currentTestState.verifyCurrentParameterHelpDocComment(docComment);
}
public currentSignatureHelpDocCommentIs(docComment: string) {
FourSlash.currentTestState.verifyCurrentSignatureHelpDocComment(docComment);
}
public signatureHelpCountIs(expected: number) {
FourSlash.currentTestState.verifySignatureHelpCount(expected);
}
public signatureHelpArgumentCountIs(expected: number) {
FourSlash.currentTestState.verifySignatureHelpArgumentCount(expected);
}
public currentSignatureParameterCountIs(expected: number) {
FourSlash.currentTestState.verifyCurrentSignatureHelpParameterCount(expected);
}
public currentSignatureTypeParameterCountIs(expected: number) {
FourSlash.currentTestState.verifyCurrentSignatureHelpTypeParameterCount(expected);
}
public currentSignatureHelpIs(expected: string) {
FourSlash.currentTestState.verifyCurrentSignatureHelpIs(expected);
}
public numberOfErrorsInCurrentFile(expected: number) {
FourSlash.currentTestState.verifyNumberOfErrorsInCurrentFile(expected);
}
public baselineCurrentFileBreakpointLocations() {
FourSlash.currentTestState.baselineCurrentFileBreakpointLocations();
}
public baselineCurrentFileNameOrDottedNameSpans() {
FourSlash.currentTestState.baselineCurrentFileNameOrDottedNameSpans();
}
public baselineGetEmitOutput() {
FourSlash.currentTestState.baselineGetEmitOutput();
}
public nameOrDottedNameSpanTextIs(text: string) {
FourSlash.currentTestState.verifyCurrentNameOrDottedNameSpanText(text);
}
public outliningSpansInCurrentFile(spans: TextSpan[]) {
FourSlash.currentTestState.verifyOutliningSpans(spans);
}
public todoCommentsInCurrentFile(descriptors: string[]) {
FourSlash.currentTestState.verifyTodoComments(descriptors, test.ranges());
}
public matchingBracePositionInCurrentFile(bracePosition: number, expectedMatchPosition: number) {
FourSlash.currentTestState.verifyMatchingBracePosition(bracePosition, expectedMatchPosition);
}
public noMatchingBracePositionInCurrentFile(bracePosition: number) {
FourSlash.currentTestState.verifyNoMatchingBracePosition(bracePosition);
}
public DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean) {
FourSlash.currentTestState.verifyDocCommentTemplate(empty ? undefined : { newText: expectedText, caretOffset: expectedOffset });
}
public noDocCommentTemplate() {
this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, true);
}
public getScriptLexicalStructureListCount(count: number) {
FourSlash.currentTestState.verifyGetScriptLexicalStructureListCount(count);
}
// TODO: figure out what to do with the unused arguments.
public getScriptLexicalStructureListContains(
name: string,
kind: string,
fileName?: string,
parentName?: string,
isAdditionalSpan?: boolean,
markerPosition?: number) {
FourSlash.currentTestState.verifyGetScriptLexicalStructureListContains(name, kind);
}
public navigationItemsListCount(count: number, searchValue: string, matchKind?: string) {
FourSlash.currentTestState.verifyNavigationItemsCount(count, searchValue, matchKind);
}
public navigationItemsListContains(
name: string,
kind: string,
searchValue: string,
matchKind: string,
fileName?: string,
parentName?: string) {
FourSlash.currentTestState.verifyNavigationItemsListContains(
name,
kind,
searchValue,
matchKind,
fileName,
parentName);
}
public occurrencesAtPositionContains(range: Range, isWriteAccess?: boolean) {
FourSlash.currentTestState.verifyOccurrencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess);
}
public occurrencesAtPositionCount(expectedCount: number) {
FourSlash.currentTestState.verifyOccurrencesAtPositionListCount(expectedCount);
}
public documentHighlightsAtPositionContains(range: Range, fileNamesToSearch: string[], kind?: string) {
FourSlash.currentTestState.verifyDocumentHighlightsAtPositionListContains(range.fileName, range.start, range.end, fileNamesToSearch, kind);
}
public documentHighlightsAtPositionCount(expectedCount: number, fileNamesToSearch: string[]) {
FourSlash.currentTestState.verifyDocumentHighlightsAtPositionListCount(expectedCount, fileNamesToSearch);
}
public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string) {
FourSlash.currentTestState.verifyCompletionEntryDetails(entryName, text, documentation, kind);
}
eval(expr: string, value: any): void;
currentLineContentIs(text: string): void;
currentFileContentIs(text: string): void;
verifyGetEmitOutputForCurrentFile(expected: string): void;
currentParameterHelpArgumentNameIs(name: string): void;
currentParameterSpanIs(parameter: string): void;
currentParameterHelpArgumentDocCommentIs(docComment: string): void;
currentSignatureHelpDocCommentIs(docComment: string): void;
signatureHelpCountIs(expected: number): void;
signatureHelpArgumentCountIs(expected: number): void;
currentSignatureParameterCountIs(expected: number): void;
currentSignatureTypeParameterCountIs(expected: number): void;
currentSignatureHelpIs(expected: string): void;
numberOfErrorsInCurrentFile(expected: number): void;
baselineCurrentFileBreakpointLocations(): void;
baselineCurrentFileNameOrDottedNameSpans(): void;
baselineGetEmitOutput(): void;
nameOrDottedNameSpanTextIs(text: string): void;
outliningSpansInCurrentFile(spans: TextSpan[]): void;
todoCommentsInCurrentFile(descriptors: string[]): void;
matchingBracePositionInCurrentFile(bracePosition: number, expectedMatchPosition: number): void;
noMatchingBracePositionInCurrentFile(bracePosition: number): void;
DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void;
noDocCommentTemplate(): void;
getScriptLexicalStructureListCount(count: number): void;
getScriptLexicalStructureListContains(name: string, kind: string, fileName?: string, parentName?: string, isAdditionalSpan?: boolean, markerPosition?: number): void;
navigationItemsListCount(count: number, searchValue: string, matchKind?: string): void;
navigationItemsListContains(name: string, kind: string, searchValue: string, matchKind: string, fileName?: string, parentName?: string): void;
occurrencesAtPositionContains(range: Range, isWriteAccess?: boolean): void;
occurrencesAtPositionCount(expectedCount: number): void;
documentHighlightsAtPositionContains(range: Range, fileNamesToSearch: string[], kind?: string): void;
documentHighlightsAtPositionCount(expectedCount: number, fileNamesToSearch: string[]): void;
completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string): void;
/**
* This method *requires* a contiguous, complete, and ordered stream of classifications for a file.
*/
public syntacticClassificationsAre(...classifications: { classificationType: string; text: string }[]) {
FourSlash.currentTestState.verifySyntacticClassifications(classifications);
}
syntacticClassificationsAre(...classifications: {
classificationType: string;
text: string;
}[]): void;
/**
* This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
*/
public semanticClassificationsAre(...classifications: { classificationType: string; text: string; textSpan?: TextSpan }[]) {
FourSlash.currentTestState.verifySemanticClassifications(classifications);
}
public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string) {
FourSlash.currentTestState.verifyRenameInfoSucceeded(displayName, fullDisplayName, kind, kindModifiers)
}
public renameInfoFailed(message?: string) {
FourSlash.currentTestState.verifyRenameInfoFailed(message)
}
public renameLocations(findInStrings: boolean, findInComments: boolean) {
FourSlash.currentTestState.verifyRenameLocations(findInStrings, findInComments);
}
public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: { start: number; length: number; },
displayParts: ts.SymbolDisplayPart[], documentation: ts.SymbolDisplayPart[]) {
FourSlash.currentTestState.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation);
}
public getSyntacticDiagnostics(expected: string) {
FourSlash.currentTestState.getSyntacticDiagnostics(expected);
}
public getSemanticDiagnostics(expected: string) {
FourSlash.currentTestState.getSemanticDiagnostics(expected);
}
public ProjectInfo(expected: string []) {
FourSlash.currentTestState.verifyProjectInfo(expected);
}
semanticClassificationsAre(...classifications: {
classificationType: string;
text: string;
textSpan?: TextSpan;
}[]): void;
renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string): void;
renameInfoFailed(message?: string): void;
renameLocations(findInStrings: boolean, findInComments: boolean): void;
verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: {
start: number;
length: number;
}, displayParts: ts.SymbolDisplayPart[], documentation: ts.SymbolDisplayPart[]): void;
getSyntacticDiagnostics(expected: string): void;
getSemanticDiagnostics(expected: string): void;
ProjectInfo(expected: string[]): void;
}
export class edit {
public backspace(count?: number) {
FourSlash.currentTestState.deleteCharBehindMarker(count);
}
public deleteAtCaret(times?: number) {
FourSlash.currentTestState.deleteChar(times);
}
public replace(start: number, length: number, text: string) {
FourSlash.currentTestState.replace(start, length, text);
}
public paste(text: string) {
FourSlash.currentTestState.paste(text);
}
public insert(text: string) {
this.insertLines(text);
}
public insertLine(text: string) {
this.insertLines(text + '\n');
}
public insertLines(...lines: string[]) {
FourSlash.currentTestState.type(lines.join('\n'));
}
public moveRight(count?: number) {
FourSlash.currentTestState.moveCaretRight(count);
}
public moveLeft(count?: number) {
if (typeof count === 'undefined') {
count = 1;
}
FourSlash.currentTestState.moveCaretRight(count * -1);
}
public enableFormatting() {
FourSlash.currentTestState.enableFormatting = true;
}
public disableFormatting() {
FourSlash.currentTestState.enableFormatting = false;
}
class edit {
backspace(count?: number): void;
deleteAtCaret(times?: number): void;
replace(start: number, length: number, text: string): void;
paste(text: string): void;
insert(text: string): void;
insertLine(text: string): void;
insertLines(...lines: string[]): void;
moveRight(count?: number): void;
moveLeft(count?: number): void;
enableFormatting(): void;
disableFormatting(): void;
}
export class debug {
public printCurrentParameterHelp() {
FourSlash.currentTestState.printCurrentParameterHelp();
}
public printCurrentFileState() {
FourSlash.currentTestState.printCurrentFileState();
}
public printCurrentFileStateWithWhitespace() {
FourSlash.currentTestState.printCurrentFileState(/*withWhiteSpace=*/true);
}
public printCurrentFileStateWithoutCaret() {
FourSlash.currentTestState.printCurrentFileState(/*withWhiteSpace=*/false, /*withCaret=*/false);
}
public printCurrentQuickInfo() {
FourSlash.currentTestState.printCurrentQuickInfo();
}
public printCurrentSignatureHelp() {
FourSlash.currentTestState.printCurrentSignatureHelp();
}
public printMemberListMembers() {
FourSlash.currentTestState.printMemberListMembers();
}
public printCompletionListMembers() {
FourSlash.currentTestState.printCompletionListMembers();
}
public printBreakpointLocation(pos: number) {
FourSlash.currentTestState.printBreakpointLocation(pos);
}
public printBreakpointAtCurrentLocation() {
FourSlash.currentTestState.printBreakpointAtCurrentLocation();
}
public printNameOrDottedNameSpans(pos: number) {
FourSlash.currentTestState.printNameOrDottedNameSpans(pos);
}
public printErrorList() {
FourSlash.currentTestState.printErrorList();
}
public printNavigationItems(searchValue: string = ".*") {
FourSlash.currentTestState.printNavigationItems(searchValue);
}
public printScriptLexicalStructureItems() {
FourSlash.currentTestState.printScriptLexicalStructureItems();
}
public printReferences() {
FourSlash.currentTestState.printReferences();
}
public printContext() {
FourSlash.currentTestState.printContext();
}
class debug {
printCurrentParameterHelp(): void;
printCurrentFileState(): void;
printCurrentFileStateWithWhitespace(): void;
printCurrentFileStateWithoutCaret(): void;
printCurrentQuickInfo(): void;
printCurrentSignatureHelp(): void;
printMemberListMembers(): void;
printCompletionListMembers(): void;
printBreakpointLocation(pos: number): void;
printBreakpointAtCurrentLocation(): void;
printNameOrDottedNameSpans(pos: number): void;
printErrorList(): void;
printNavigationItems(searchValue?: string): void;
printScriptLexicalStructureItems(): void;
printReferences(): void;
printContext(): void;
}
export class format {
public document() {
FourSlash.currentTestState.formatDocument();
}
public copyFormatOptions(): FormatCodeOptions {
return FourSlash.currentTestState.copyFormatOptions();
}
public setFormatOptions(options: FormatCodeOptions) {
return FourSlash.currentTestState.setFormatOptions(options);
}
public selection(startMarker: string, endMarker: string) {
FourSlash.currentTestState.formatSelection(FourSlash.currentTestState.getMarkerByName(startMarker).position, FourSlash.currentTestState.getMarkerByName(endMarker).position);
}
public setOption(name: string, value: number);
public setOption(name: string, value: string);
public setOption(name: string, value: boolean);
public setOption(name: string, value: any) {
FourSlash.currentTestState.formatCodeOptions[name] = value;
}
class format {
document(): void;
copyFormatOptions(): FormatCodeOptions;
setFormatOptions(options: FormatCodeOptions): any;
selection(startMarker: string, endMarker: string): void;
setOption(name: string, value: number): any;
setOption(name: string, value: string): any;
setOption(name: string, value: boolean): any;
}
export class cancellation {
public resetCancelled() {
FourSlash.currentTestState.resetCancelled();
}
public setCancelled(numberOfCalls: number = 0) {
FourSlash.currentTestState.setCancelled(numberOfCalls);
}
class cancellation {
resetCancelled(): void;
setCancelled(numberOfCalls?: number): void;
}
export module classification {
export function comment(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("comment", text, position);
}
export function identifier(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("identifier", text, position);
}
export function keyword(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("keyword", text, position);
}
export function numericLiteral(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("numericLiteral", text, position);
}
export function operator(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("operator", text, position);
}
export function stringLiteral(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("stringLiteral", text, position);
}
export function whiteSpace(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("whiteSpace", text, position);
}
export function text(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("text", text, position);
}
export function punctuation(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("punctuation", text, position);
}
export function docCommentTagName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("docCommentTagName", text, position);
}
export function className(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("className", text, position);
}
export function enumName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("enumName", text, position);
}
export function interfaceName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("interfaceName", text, position);
}
export function moduleName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("moduleName", text, position);
}
export function typeParameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("typeParameterName", text, position);
}
export function parameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("parameterName", text, position);
}
export function typeAliasName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
return getClassification("typeAliasName", text, position);
}
function getClassification(type: string, text: string, position?: number) {
return {
classificationType: type,
text: text,
textSpan: position === undefined ? undefined : { start: position, end: position + text.length }
};
}
module classification {
function comment(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function identifier(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function keyword(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function numericLiteral(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function operator(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function stringLiteral(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function whiteSpace(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function text(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function punctuation(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function docCommentTagName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function className(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function enumName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function interfaceName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function moduleName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function typeParameterName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function parameterName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
function typeAliasName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
}
}
module fs {
export var test = new FourSlashInterface.test_();
export var goTo = new FourSlashInterface.goTo();
export var verify = new FourSlashInterface.verify();
export var edit = new FourSlashInterface.edit();
export var debug = new FourSlashInterface.debug();
export var format = new FourSlashInterface.format();
export var cancellation = new FourSlashInterface.cancellation();
}
function verifyOperationIsCancelled(f) {
FourSlash.verifyOperationIsCancelled(f);
}
var test = new FourSlashInterface.test_();
var goTo = new FourSlashInterface.goTo();
var verify = new FourSlashInterface.verify();
var edit = new FourSlashInterface.edit();
var debug = new FourSlashInterface.debug();
var format = new FourSlashInterface.format();
var cancellation = new FourSlashInterface.cancellation();
var classification = FourSlashInterface.classification;
declare function verifyOperationIsCancelled(f: any): void;
declare var test: FourSlashInterface.test_;
declare var goTo: FourSlashInterface.goTo;
declare var verify: FourSlashInterface.verify;
declare var edit: FourSlashInterface.edit;
declare var debug: FourSlashInterface.debug;
declare var format: FourSlashInterface.format;
declare var cancellation: FourSlashInterface.cancellation;
declare var classification: typeof FourSlashInterface.classification;

View File

@@ -179,5 +179,5 @@
////{| "indent": 0 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent, IndentStyle.Block);
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent, ts.IndentStyle.Block);
});

View File

@@ -179,5 +179,5 @@
////{| "indent": 0 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent, IndentStyle.None);
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent, ts.IndentStyle.None);
});

View File

@@ -11,4 +11,4 @@
//// }
goTo.marker();
fs.verify.quickInfoExists();
verify.quickInfoExists();

View File

@@ -10,7 +10,7 @@
//// var z = y + 5;
////}
fs.goTo.marker();
fs.edit.backspace(6);
fs.edit.insert("var");
fs.verify.numberOfErrorsInCurrentFile(0);
goTo.marker();
edit.backspace(6);
edit.insert("var");
verify.numberOfErrorsInCurrentFile(0);

View File

@@ -0,0 +1,16 @@
/// <reference path="../fourslash.ts"/>
// @Filename: test1.ts
////t.
// @Filename: test.ts
////var t = '10';
// @Filename: tsconfig.json
////{ "files": ["test.ts", "test1.ts"] }
var overridingContent = "var t = 10; t.";
goTo.file("test.ts", overridingContent);
goTo.file("test1.ts");
goTo.eof();
verify.completionListContains("toExponential");

View File

@@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
////class Circle {
//// /**
//// * Initialize a circle.
//// * @param radius The radius of the circle.
//// */
//// constructor(private radius: number) {
//// }
////}
////var a = new Circle(/**/
goTo.marker('');
verify.signatureHelpCountIs(1);
verify.currentSignatureHelpIs("Circle(radius: number): Circle");
verify.currentParameterHelpArgumentNameIs("radius");
verify.currentParameterSpanIs("radius: number");
verify.currentParameterHelpArgumentDocCommentIs("The radius of the circle.");

View File

@@ -354,6 +354,31 @@ export = C;
"moduleC.ts": "export var x"
};
test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /* useCaseSensitiveFileNames */ false, ["moduleA.ts", "moduleB.ts", "moduleC.ts"], [1149, 1149]);
});
it("should fail when module names in 'require' calls has inconsistent casing and current directory has uppercase chars", () => {
const files: Map<string> = {
"/a/B/c/moduleA.ts": `import a = require("./ModuleC")`,
"/a/B/c/moduleB.ts": `import a = require("./moduleC")`,
"/a/B/c/moduleC.ts": "export var x",
"/a/B/c/moduleD.ts": `
import a = require("./moduleA.ts");
import b = require("./moduleB.ts");
`
};
test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /* useCaseSensitiveFileNames */ false, ["moduleD.ts"], [1149]);
});
it("should not fail when module names in 'require' calls has consistent casing and current directory has uppercase chars", () => {
const files: Map<string> = {
"/a/B/c/moduleA.ts": `import a = require("./moduleC")`,
"/a/B/c/moduleB.ts": `import a = require("./moduleC")`,
"/a/B/c/moduleC.ts": "export var x",
"/a/B/c/moduleD.ts": `
import a = require("./moduleA.ts");
import b = require("./moduleB.ts");
`
};
test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /* useCaseSensitiveFileNames */ false, ["moduleD.ts"], []);
})
});
}

View File

@@ -20,7 +20,10 @@ module ts {
}
describe('VersionCache TS code', () => {
var testContent = `/// <reference path="z.ts" />
let validateEditAtLineCharIndex: (line: number, char: number, deleteLength: number, insertString: string) => void;
before(() => {
let testContent = `/// <reference path="z.ts" />
var x = 10;
var y = { zebra: 12, giraffe: "ell" };
z.a;
@@ -31,16 +34,21 @@ k=y;
var p:Point=new Point();
var q:Point=<Point>p;`
let {lines, lineMap} = server.LineIndex.linesFromText(testContent);
assert.isTrue(lines.length > 0, "Failed to initialize test text. Expected text to have at least one line");
let {lines, lineMap} = server.LineIndex.linesFromText(testContent);
assert.isTrue(lines.length > 0, "Failed to initialize test text. Expected text to have at least one line");
let lineIndex = new server.LineIndex();
lineIndex.load(lines);
let lineIndex = new server.LineIndex();
lineIndex.load(lines);
function validateEditAtLineCharIndex(line: number, char: number, deleteLength: number, insertString: string): void {
let position = lineColToPosition(lineIndex, line, char);
validateEdit(lineIndex, testContent, position, deleteLength, insertString);
}
validateEditAtLineCharIndex = (line: number, char: number, deleteLength: number, insertString: string) => {
let position = lineColToPosition(lineIndex, line, char);
validateEdit(lineIndex, testContent, position, deleteLength, insertString);
};
});
after(() => {
validateEditAtLineCharIndex = undefined;
})
it('change 9 1 0 1 {"y"}', () => {
validateEditAtLineCharIndex(9, 1, 0, "y");
@@ -68,22 +76,35 @@ var q:Point=<Point>p;`
});
describe('VersionCache simple text', () => {
let testContent = `in this story:
let validateEditAtPosition: (position: number, deleteLength: number, insertString: string) => void;
let testContent: string;
let lines: string[];
let lineMap: number[];
before(() => {
testContent = `in this story:
the lazy brown fox
jumped over the cow
that ate the grass
that was purple at the tips
and grew 1cm per day`;
let {lines, lineMap} = server.LineIndex.linesFromText(testContent);
assert.isTrue(lines.length > 0, "Failed to initialize test text. Expected text to have at least one line");
({lines, lineMap} = server.LineIndex.linesFromText(testContent));
assert.isTrue(lines.length > 0, "Failed to initialize test text. Expected text to have at least one line");
let lineIndex = new server.LineIndex();
lineIndex.load(lines);
let lineIndex = new server.LineIndex();
lineIndex.load(lines);
function validateEditAtPosition(position: number, deleteLength: number, insertString: string): void {
validateEdit(lineIndex, testContent, position, deleteLength, insertString);
}
validateEditAtPosition = (position: number, deleteLength: number, insertString: string) => {
validateEdit(lineIndex, testContent, position, deleteLength, insertString);
}
});
after(() => {
validateEditAtPosition = undefined;
testContent = undefined;
lines = undefined;
lineMap = undefined;
});
it('Insert at end of file', () => {
validateEditAtPosition(testContent.length, 0, "hmmmm...\r\n");
@@ -159,50 +180,69 @@ and grew 1cm per day`;
});
describe('VersionCache stress test', () => {
const iterationCount = 20;
//const interationCount = 20000; // uncomment for testing
// Use scanner.ts, decent size, does not change frequentlly
let testFileName = "src/compiler/scanner.ts";
let testContent = Harness.IO.readFile(testFileName);
let totalChars = testContent.length;
assert.isTrue(totalChars > 0, "Failed to read test file.");
let {lines, lineMap} = server.LineIndex.linesFromText(testContent);
assert.isTrue(lines.length > 0, "Failed to initialize test text. Expected text to have at least one line");
let lineIndex = new server.LineIndex();
lineIndex.load(lines);
let rsa: number[] = [];
let la: number[] = [];
let las: number[] = [];
let elas: number[] = [];
let ersa: number[] = [];
let ela: number[] = [];
let etotalChars = totalChars;
const iterationCount = 20;
//const iterationCount = 20000; // uncomment for testing
let lines: string[];
let lineMap: number[];
let lineIndex: server.LineIndex;
let testContent: string;
for (let j = 0; j < 100000; j++) {
rsa[j] = Math.floor(Math.random() * totalChars);
la[j] = Math.floor(Math.random() * (totalChars - rsa[j]));
if (la[j] > 4) {
las[j] = 4;
}
else {
las[j] = la[j];
}
if (j < 4000) {
ersa[j] = Math.floor(Math.random() * etotalChars);
ela[j] = Math.floor(Math.random() * (etotalChars - ersa[j]));
if (ela[j] > 4) {
elas[j] = 4;
before(() => {
// Use scanner.ts, decent size, does not change frequently
let testFileName = "src/compiler/scanner.ts";
testContent = Harness.IO.readFile(testFileName);
let totalChars = testContent.length;
assert.isTrue(totalChars > 0, "Failed to read test file.");
({lines, lineMap} = server.LineIndex.linesFromText(testContent));
assert.isTrue(lines.length > 0, "Failed to initialize test text. Expected text to have at least one line");
lineIndex = new server.LineIndex();
lineIndex.load(lines);
let etotalChars = totalChars;
for (let j = 0; j < 100000; j++) {
rsa[j] = Math.floor(Math.random() * totalChars);
la[j] = Math.floor(Math.random() * (totalChars - rsa[j]));
if (la[j] > 4) {
las[j] = 4;
}
else {
elas[j] = ela[j];
las[j] = la[j];
}
if (j < 4000) {
ersa[j] = Math.floor(Math.random() * etotalChars);
ela[j] = Math.floor(Math.random() * (etotalChars - ersa[j]));
if (ela[j] > 4) {
elas[j] = 4;
}
else {
elas[j] = ela[j];
}
etotalChars += (las[j] - elas[j]);
}
etotalChars += (las[j] - elas[j]);
}
}
});
after(() => {
rsa = undefined;
la = undefined;
las = undefined;
elas = undefined;
ersa = undefined;
ela = undefined;
lines = undefined;
lineMap = undefined;
lineIndex = undefined;
testContent = undefined;
});
it("Range (average length 1/4 file size)", () => {
for (let i = 0; i < iterationCount; i++) {

View File

@@ -269,6 +269,9 @@ if ((browser && browser === 'chrome')) {
case "win64":
defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe";
break;
case "darwin":
defaultChromePath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
break;
case "linux":
defaultChromePath = "/opt/google/chrome/chrome"
break;