mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Merge branch 'master' into compute-common-source-dir
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
})();
|
||||
@@ -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'.
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
})();
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [sourceMapValidationLambdaSpanningMultipleLines.ts]
|
||||
((item: string) =>
|
||||
item
|
||||
)
|
||||
|
||||
//// [sourceMapValidationLambdaSpanningMultipleLines.js]
|
||||
(function (item) {
|
||||
return item;
|
||||
});
|
||||
//# sourceMappingURL=sourceMapValidationLambdaSpanningMultipleLines.js.map
|
||||
@@ -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"}
|
||||
@@ -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
|
||||
@@ -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))
|
||||
|
||||
)
|
||||
@@ -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
|
||||
|
||||
)
|
||||
357
tests/baselines/reference/typeGuardTypeOfUndefined.js
Normal file
357
tests/baselines/reference/typeGuardTypeOfUndefined.js
Normal 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;
|
||||
}
|
||||
}
|
||||
330
tests/baselines/reference/typeGuardTypeOfUndefined.symbols
Normal file
330
tests/baselines/reference/typeGuardTypeOfUndefined.symbols
Normal 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))
|
||||
}
|
||||
}
|
||||
|
||||
434
tests/baselines/reference/typeGuardTypeOfUndefined.types
Normal file
434
tests/baselines/reference/typeGuardTypeOfUndefined.types
Normal 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
15
tests/cases/compiler/mixedStaticAndInstanceClassMembers.ts
Normal file
15
tests/cases/compiler/mixedStaticAndInstanceClassMembers.ts
Normal 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 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class A {
|
||||
m1: string;
|
||||
f() {}
|
||||
m1 (a: string): void;
|
||||
m1 (a: number): void;
|
||||
m1 (a: any): void {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// @sourcemap: true
|
||||
((item: string) =>
|
||||
item
|
||||
)
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -169,10 +169,10 @@ module FourSlashInterface {
|
||||
// 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);
|
||||
public file(index: number, content?: string);
|
||||
public file(name: string, content?: string);
|
||||
public file(indexOrName: any, content?: string) {
|
||||
FourSlash.currentTestState.openFile(indexOrName, content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
tests/cases/fourslash/server/openFile.ts
Normal file
16
tests/cases/fourslash/server/openFile.ts
Normal 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");
|
||||
Reference in New Issue
Block a user