diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3d25fc8bbbb0d..6928ce73d311b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3238,9 +3238,11 @@ namespace ts { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - if (declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) && + if ((compilerOptions.noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) && + declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) && !(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !isInAmbientContext(declaration)) { - // Use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no + // If --noImplicitAny is on or the declaration is in a Javascript file, + // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. if (!(getCombinedNodeFlags(declaration) & NodeFlags.Const) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; diff --git a/tests/baselines/reference/asiPreventsParsingAsTypeAlias01.types b/tests/baselines/reference/asiPreventsParsingAsTypeAlias01.types index c2d9213ca6045..7492a698e3a26 100644 --- a/tests/baselines/reference/asiPreventsParsingAsTypeAlias01.types +++ b/tests/baselines/reference/asiPreventsParsingAsTypeAlias01.types @@ -10,10 +10,10 @@ var Foo; >Foo : any type ->type : undefined +>type : any Foo = string; ->Foo = string : undefined +>Foo = string : any >Foo : any ->string : undefined +>string : any diff --git a/tests/baselines/reference/assignEveryTypeToAny.types b/tests/baselines/reference/assignEveryTypeToAny.types index fd1dccefae059..cfc24e1da65b8 100644 --- a/tests/baselines/reference/assignEveryTypeToAny.types +++ b/tests/baselines/reference/assignEveryTypeToAny.types @@ -59,9 +59,9 @@ var e = undefined; >undefined : undefined x = e; ->x = e : undefined +>x = e : any >x : any ->e : undefined +>e : any var e2: typeof undefined; >e2 : any diff --git a/tests/baselines/reference/capturedLetConstInLoop3.types b/tests/baselines/reference/capturedLetConstInLoop3.types index 1fee8db67c4a4..8ce40ab5f1b5e 100644 --- a/tests/baselines/reference/capturedLetConstInLoop3.types +++ b/tests/baselines/reference/capturedLetConstInLoop3.types @@ -179,7 +179,7 @@ function foo3(x) { use(v); >use(v) : any >use : (a: any) => any ->v : undefined +>v : any } function foo4(x) { @@ -283,8 +283,8 @@ function foo6(x) { >y : any var v = x; ->v : undefined ->x : undefined +>v : any +>x : any (function() { return x + y + v }); >(function() { return x + y + v }) : () => any @@ -293,7 +293,7 @@ function foo6(x) { >x + y : any >x : any >y : any ->v : undefined +>v : any (() => x + y + v); >(() => x + y + v) : () => any @@ -302,13 +302,13 @@ function foo6(x) { >x + y : any >x : any >y : any ->v : undefined +>v : any } use(v) >use(v) : any >use : (a: any) => any ->v : undefined +>v : any } function foo7(x) { @@ -321,8 +321,8 @@ function foo7(x) { >y : any var v = x; ->v : undefined ->x : undefined +>v : any +>x : any (function() { return x + y + v }); >(function() { return x + y + v }) : () => any @@ -331,7 +331,7 @@ function foo7(x) { >x + y : any >x : any >y : any ->v : undefined +>v : any (() => x + y + v); >(() => x + y + v) : () => any @@ -340,7 +340,7 @@ function foo7(x) { >x + y : any >x : any >y : any ->v : undefined +>v : any } while (1 === 1); >1 === 1 : boolean @@ -350,7 +350,7 @@ function foo7(x) { use(v); >use(v) : any >use : (a: any) => any ->v : undefined +>v : any } @@ -574,7 +574,7 @@ function foo3_c(x) { use(v); >use(v) : any >use : (a: any) => any ->v : undefined +>v : any } function foo4_c(x) { diff --git a/tests/baselines/reference/capturedLetConstInLoop3_ES6.types b/tests/baselines/reference/capturedLetConstInLoop3_ES6.types index bfd279afdff15..9c11ae625744c 100644 --- a/tests/baselines/reference/capturedLetConstInLoop3_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop3_ES6.types @@ -180,7 +180,7 @@ function foo3(x) { use(v); >use(v) : any >use : (a: any) => any ->v : undefined +>v : any } function foo4(x) { @@ -284,8 +284,8 @@ function foo6(x) { >y : any var v = x; ->v : undefined ->x : undefined +>v : any +>x : any (function() { return x + y + v }); >(function() { return x + y + v }) : () => any @@ -294,7 +294,7 @@ function foo6(x) { >x + y : any >x : any >y : any ->v : undefined +>v : any (() => x + y + v); >(() => x + y + v) : () => any @@ -303,13 +303,13 @@ function foo6(x) { >x + y : any >x : any >y : any ->v : undefined +>v : any } use(v) >use(v) : any >use : (a: any) => any ->v : undefined +>v : any } function foo7(x) { @@ -322,8 +322,8 @@ function foo7(x) { >y : any var v = x; ->v : undefined ->x : undefined +>v : any +>x : any (function() { return x + y + v }); >(function() { return x + y + v }) : () => any @@ -332,7 +332,7 @@ function foo7(x) { >x + y : any >x : any >y : any ->v : undefined +>v : any (() => x + y + v); >(() => x + y + v) : () => any @@ -341,7 +341,7 @@ function foo7(x) { >x + y : any >x : any >y : any ->v : undefined +>v : any } while (1 === 1); >1 === 1 : boolean @@ -351,7 +351,7 @@ function foo7(x) { use(v); >use(v) : any >use : (a: any) => any ->v : undefined +>v : any } @@ -575,7 +575,7 @@ function foo3_c(x) { use(v); >use(v) : any >use : (a: any) => any ->v : undefined +>v : any } function foo4_c(x) { diff --git a/tests/baselines/reference/capturedLetConstInLoop4.types b/tests/baselines/reference/capturedLetConstInLoop4.types index 0feff77f60429..2c48463adec70 100644 --- a/tests/baselines/reference/capturedLetConstInLoop4.types +++ b/tests/baselines/reference/capturedLetConstInLoop4.types @@ -17,12 +17,12 @@ export function exportedFoo() { >v0 : any >v00 : string >v1 : number ->v2 : undefined ->v3 : undefined +>v2 : any +>v3 : any >v4 : number >v5 : number ->v6 : undefined ->v7 : undefined +>v6 : any +>v7 : any >v8 : number } @@ -103,15 +103,15 @@ while (1 === 1) { >x : any var v2 = x; ->v2 : undefined ->x : undefined +>v2 : any +>x : any (function() { return x + v2}); >(function() { return x + v2}) : () => any >function() { return x + v2} : () => any >x + v2 : any >x : any ->v2 : undefined +>v2 : any (() => x); >(() => x) : () => any @@ -124,15 +124,15 @@ do { >x : any var v3 = x; ->v3 : undefined ->x : undefined +>v3 : any +>x : any (function() { return x + v3}); >(function() { return x + v3}) : () => any >function() { return x + v3} : () => any >x + v3 : any >x : any ->v3 : undefined +>v3 : any (() => x); >(() => x) : () => any @@ -216,8 +216,8 @@ while (1 === 1) { >y : any var v6 = x; ->v6 : undefined ->x : undefined +>v6 : any +>x : any (function() { return x + y + v6}); >(function() { return x + y + v6}) : () => any @@ -226,7 +226,7 @@ while (1 === 1) { >x + y : any >x : any >y : any ->v6 : undefined +>v6 : any (() => x + y); >(() => x + y) : () => any @@ -242,8 +242,8 @@ do { >y : any var v7 = x; ->v7 : undefined ->x : undefined +>v7 : any +>x : any (function() { return x + y + v7}); >(function() { return x + y + v7}) : () => any @@ -252,7 +252,7 @@ do { >x + y : any >x : any >y : any ->v7 : undefined +>v7 : any (() => x + y); >(() => x + y) : () => any diff --git a/tests/baselines/reference/capturedLetConstInLoop4_ES6.types b/tests/baselines/reference/capturedLetConstInLoop4_ES6.types index 301a6ef90f1c3..32af60f24e4f8 100644 --- a/tests/baselines/reference/capturedLetConstInLoop4_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop4_ES6.types @@ -17,12 +17,12 @@ export function exportedFoo() { >v0 : any >v00 : string >v1 : number ->v2 : undefined ->v3 : undefined +>v2 : any +>v3 : any >v4 : number >v5 : number ->v6 : undefined ->v7 : undefined +>v6 : any +>v7 : any >v8 : number } @@ -103,15 +103,15 @@ while (1 === 1) { >x : any var v2 = x; ->v2 : undefined ->x : undefined +>v2 : any +>x : any (function() { return x + v2}); >(function() { return x + v2}) : () => any >function() { return x + v2} : () => any >x + v2 : any >x : any ->v2 : undefined +>v2 : any (() => x); >(() => x) : () => any @@ -124,15 +124,15 @@ do { >x : any var v3 = x; ->v3 : undefined ->x : undefined +>v3 : any +>x : any (function() { return x + v3}); >(function() { return x + v3}) : () => any >function() { return x + v3} : () => any >x + v3 : any >x : any ->v3 : undefined +>v3 : any (() => x); >(() => x) : () => any @@ -216,8 +216,8 @@ while (1 === 1) { >y : any var v6 = x; ->v6 : undefined ->x : undefined +>v6 : any +>x : any (function() { return x + y + v6}); >(function() { return x + y + v6}) : () => any @@ -226,7 +226,7 @@ while (1 === 1) { >x + y : any >x : any >y : any ->v6 : undefined +>v6 : any (() => x + y); >(() => x + y) : () => any @@ -242,8 +242,8 @@ do { >y : any var v7 = x; ->v7 : undefined ->x : undefined +>v7 : any +>x : any (function() { return x + y + v7}); >(function() { return x + y + v7}) : () => any @@ -252,7 +252,7 @@ do { >x + y : any >x : any >y : any ->v7 : undefined +>v7 : any (() => x + y); >(() => x + y) : () => any diff --git a/tests/baselines/reference/capturedLetConstInLoop9.types b/tests/baselines/reference/capturedLetConstInLoop9.types index 453176a40c92f..486697b8d8409 100644 --- a/tests/baselines/reference/capturedLetConstInLoop9.types +++ b/tests/baselines/reference/capturedLetConstInLoop9.types @@ -39,7 +39,7 @@ for (let x = 0; x < 1; ++x) { } switch (x) { ->x : undefined +>x : any case 1: >1 : 1 diff --git a/tests/baselines/reference/capturedLetConstInLoop9_ES6.types b/tests/baselines/reference/capturedLetConstInLoop9_ES6.types index df118279f3022..be4457315eeeb 100644 --- a/tests/baselines/reference/capturedLetConstInLoop9_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop9_ES6.types @@ -40,7 +40,7 @@ for (let x = 0; x < 1; ++x) { } switch (x) { ->x : undefined +>x : any case 1: >1 : 1 diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression2.types b/tests/baselines/reference/commentsArgumentsOfCallExpression2.types index bc6bf5baa90ad..7ec29aa912430 100644 --- a/tests/baselines/reference/commentsArgumentsOfCallExpression2.types +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression2.types @@ -17,7 +17,7 @@ foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); >1 : 1 >2 : 2 >a + b : any ->a : undefined +>a : any >b : any foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b); @@ -26,7 +26,7 @@ foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b); >function () { } : () => void >() => { } : () => void >a + /*e3*/ b : any ->a : undefined +>a : any >b : any foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b)); @@ -36,7 +36,7 @@ foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b)); >() => { } : () => void >(a + b) : any >a + b : any ->a : undefined +>a : any >b : any foo( diff --git a/tests/baselines/reference/compoundAssignmentLHSIsReference.types b/tests/baselines/reference/compoundAssignmentLHSIsReference.types index a82eb17426d5a..4816307f50895 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsReference.types +++ b/tests/baselines/reference/compoundAssignmentLHSIsReference.types @@ -9,12 +9,12 @@ var x1: number; x1 *= value; >x1 *= value : number >x1 : number ->value : undefined +>value : any x1 += value; ->x1 += value : number +>x1 += value : any >x1 : number ->value : undefined +>value : any function fn1(x2: number) { >fn1 : (x2: number) => void @@ -41,41 +41,41 @@ x3.a *= value; >x3.a : number >x3 : { a: number; } >a : number ->value : undefined +>value : any x3.a += value; ->x3.a += value : number +>x3.a += value : any >x3.a : number >x3 : { a: number; } >a : number ->value : undefined +>value : any x3['a'] *= value; >x3['a'] *= value : number >x3['a'] : number >x3 : { a: number; } >'a' : "a" ->value : undefined +>value : any x3['a'] += value; ->x3['a'] += value : number +>x3['a'] += value : any >x3['a'] : number >x3 : { a: number; } >'a' : "a" ->value : undefined +>value : any // parentheses, the contained expression is reference (x1) *= value; >(x1) *= value : number >(x1) : number >x1 : number ->value : undefined +>value : any (x1) += value; ->(x1) += value : number +>(x1) += value : any >(x1) : number >x1 : number ->value : undefined +>value : any function fn2(x4: number) { >fn2 : (x4: number) => void @@ -100,15 +100,15 @@ function fn2(x4: number) { >x3.a : number >x3 : { a: number; } >a : number ->value : undefined +>value : any (x3.a) += value; ->(x3.a) += value : number +>(x3.a) += value : any >(x3.a) : number >x3.a : number >x3 : { a: number; } >a : number ->value : undefined +>value : any (x3['a']) *= value; >(x3['a']) *= value : number @@ -116,13 +116,13 @@ function fn2(x4: number) { >x3['a'] : number >x3 : { a: number; } >'a' : "a" ->value : undefined +>value : any (x3['a']) += value; ->(x3['a']) += value : number +>(x3['a']) += value : any >(x3['a']) : number >x3['a'] : number >x3 : { a: number; } >'a' : "a" ->value : undefined +>value : any diff --git a/tests/baselines/reference/constraintSatisfactionWithAny.types b/tests/baselines/reference/constraintSatisfactionWithAny.types index 2f9c755328826..f3363fe1a9006 100644 --- a/tests/baselines/reference/constraintSatisfactionWithAny.types +++ b/tests/baselines/reference/constraintSatisfactionWithAny.types @@ -35,20 +35,20 @@ var a; >a : any foo(a); ->foo(a) : undefined +>foo(a) : any >foo : (x: T) => T ->a : undefined +>a : any foo2(a); ->foo2(a) : undefined +>foo2(a) : any >foo2 : (x: T) => T ->a : undefined +>a : any //foo3(a); foo4(a); ->foo4(a) : undefined +>foo4(a) : any >foo4 : (x: T) => void>(x: T) => T ->a : undefined +>a : any var b: number; >b : number @@ -84,10 +84,10 @@ class C { } var c1 = new C(a); ->c1 : C ->new C(a) : C +>c1 : C +>new C(a) : C >C : typeof C ->a : undefined +>a : any var c2 = new C(b); >c2 : C @@ -106,10 +106,10 @@ class C2 { } var c3 = new C2(a); ->c3 : C2 ->new C2(a) : C2 +>c3 : C2 +>new C2(a) : C2 >C2 : typeof C2 ->a : undefined +>a : any var c4 = new C2(b); >c4 : C2 @@ -138,10 +138,10 @@ class C4(x:T) => T> { } var c7 = new C4(a); ->c7 : C4 ->new C4(a) : C4 +>c7 : C4 +>new C4(a) : C4 >C4 : typeof C4 ->a : undefined +>a : any var c8 = new C4(b); >c8 : C4 diff --git a/tests/baselines/reference/controlFlowCaching.errors.txt b/tests/baselines/reference/controlFlowCaching.errors.txt deleted file mode 100644 index 1086695313e84..0000000000000 --- a/tests/baselines/reference/controlFlowCaching.errors.txt +++ /dev/null @@ -1,128 +0,0 @@ -tests/cases/compiler/controlFlowCaching.ts(38,17): error TS2532: Object is possibly 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(38,29): error TS2339: Property 'y' does not exist on type 'never'. -tests/cases/compiler/controlFlowCaching.ts(40,17): error TS2532: Object is possibly 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(40,29): error TS2339: Property 'x' does not exist on type 'never'. -tests/cases/compiler/controlFlowCaching.ts(42,17): error TS2532: Object is possibly 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(42,29): error TS2339: Property 'y' does not exist on type 'never'. -tests/cases/compiler/controlFlowCaching.ts(44,17): error TS2532: Object is possibly 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(44,29): error TS2339: Property 'y' does not exist on type 'never'. -tests/cases/compiler/controlFlowCaching.ts(46,17): error TS2532: Object is possibly 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(46,29): error TS2339: Property 'y' does not exist on type 'never'. -tests/cases/compiler/controlFlowCaching.ts(48,17): error TS2532: Object is possibly 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(48,29): error TS2339: Property 'y' does not exist on type 'never'. -tests/cases/compiler/controlFlowCaching.ts(53,5): error TS2532: Object is possibly 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(53,14): error TS2339: Property 'y' does not exist on type 'never'. -tests/cases/compiler/controlFlowCaching.ts(55,14): error TS2678: Type '"start"' is not comparable to type 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(58,14): error TS2678: Type '"end"' is not comparable to type 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(61,14): error TS2678: Type '"middle"' is not comparable to type 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(62,13): error TS2532: Object is possibly 'undefined'. -tests/cases/compiler/controlFlowCaching.ts(62,25): error TS2339: Property 'y' does not exist on type 'never'. - - -==== tests/cases/compiler/controlFlowCaching.ts (19 errors) ==== - - // Repro for #8401 - - function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { - var isRtl = this._isRtl(); // chart mirroring - // prepare variable - var o = this.opt, ta = this.chart.theme.axis, position = o.position, - leftBottom = position !== "rightOrTop", rotation = o.rotation % 360, - start, stop, titlePos, titleRotation = 0, titleOffset, axisVector, tickVector, anchorOffset, labelOffset, labelAlign, - labelGap = this.chart.theme.axis.tick.labelGap, - taFont = o.font || (ta.majorTick && ta.majorTick.font) || (ta.tick && ta.tick.font), - taTitleFont = o.titleFont || (ta.title && ta.title.font), - taFontColor = o.fontColor || (ta.majorTick && ta.majorTick.fontColor) || (ta.tick && ta.tick.fontColor) || "black", - taTitleFontColor = o.titleFontColor || (ta.title && ta.title.fontColor) || "black", - taTitleGap = (o.titleGap == 0) ? 0 : o.titleGap || (ta.title && ta.title.gap) || 15, - taTitleOrientation = o.titleOrientation || (ta.title && ta.title.orientation) || "axis", - taMajorTick = this.chart.theme.getTick("major", o), - taMinorTick = this.chart.theme.getTick("minor", o), - taMicroTick = this.chart.theme.getTick("micro", o), - - taStroke = "stroke" in o ? o.stroke : ta.stroke, - size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0, - cosr = Math.abs(Math.cos(rotation * Math.PI / 180)), - sinr = Math.abs(Math.sin(rotation * Math.PI / 180)), - tsize = taTitleFont ? g.normalizedLength(g.splitFontString(taTitleFont).size) : 0; - if (rotation < 0) { - rotation += 360; - } - var cachedLabelW = this._getMaxLabelSize(); - cachedLabelW = cachedLabelW && cachedLabelW.majLabelW; - titleOffset = size * cosr + (cachedLabelW || 0) * sinr + labelGap + Math.max(taMajorTick.length > 0 ? taMajorTick.length : 0, - taMinorTick.length > 0 ? taMinorTick.length : 0) + - tsize + taTitleGap; - axisVector = { x: isRtl ? -1 : 1, y: 0 }; // chart mirroring - switch (rotation) { - default: - if (rotation < (90 - centerAnchorLimit)) { - labelOffset.y = leftBottom ? size : 0; - ~~~~~~~~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS2339: Property 'y' does not exist on type 'never'. - } else if (rotation < (90 + centerAnchorLimit)) { - labelOffset.x = -size * 0.4; - ~~~~~~~~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS2339: Property 'x' does not exist on type 'never'. - } else if (rotation < 180) { - labelOffset.y = leftBottom ? 0 : -size; - ~~~~~~~~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS2339: Property 'y' does not exist on type 'never'. - } else if (rotation < (270 - centerAnchorLimit)) { - labelOffset.y = leftBottom ? 0 : -size; - ~~~~~~~~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS2339: Property 'y' does not exist on type 'never'. - } else if (rotation < (270 + centerAnchorLimit)) { - labelOffset.y = leftBottom ? size * 0.4 : 0; - ~~~~~~~~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS2339: Property 'y' does not exist on type 'never'. - } else { - labelOffset.y = leftBottom ? size : 0; - ~~~~~~~~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS2339: Property 'y' does not exist on type 'never'. - } - } - - titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0; - titlePos.y = offsets.t - titleOffset + (titleRotation ? 0 : tsize); - ~~~~~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS2339: Property 'y' does not exist on type 'never'. - switch (labelAlign) { - case "start": - ~~~~~~~ -!!! error TS2678: Type '"start"' is not comparable to type 'undefined'. - labelAlign = "end"; - break; - case "end": - ~~~~~ -!!! error TS2678: Type '"end"' is not comparable to type 'undefined'. - labelAlign = "start"; - break; - case "middle": - ~~~~~~~~ -!!! error TS2678: Type '"middle"' is not comparable to type 'undefined'. - labelOffset.y -= size; - ~~~~~~~~~~~ -!!! error TS2532: Object is possibly 'undefined'. - ~ -!!! error TS2339: Property 'y' does not exist on type 'never'. - break; - } - - let _ = rotation; - } - \ No newline at end of file diff --git a/tests/baselines/reference/controlFlowLetVar.js b/tests/baselines/reference/controlFlowJavascript.js similarity index 63% rename from tests/baselines/reference/controlFlowLetVar.js rename to tests/baselines/reference/controlFlowJavascript.js index 24ad95259b126..66518a6567a2c 100644 --- a/tests/baselines/reference/controlFlowLetVar.js +++ b/tests/baselines/reference/controlFlowJavascript.js @@ -1,8 +1,8 @@ -//// [controlFlowLetVar.ts] +//// [controlFlowJavascript.js] -declare let cond: boolean; +let cond = true; -// CFA for 'let' with no type annotation and initializer +// CFA for 'let' and no initializer function f1() { let x; if (cond) { @@ -14,7 +14,7 @@ function f1() { const y = x; // string | number | undefined } -// CFA for 'let' with no type annotation and 'undefined' initializer +// CFA for 'let' and 'undefined' initializer function f2() { let x = undefined; if (cond) { @@ -26,7 +26,7 @@ function f2() { const y = x; // string | number | undefined } -// CFA for 'let' with no type annotation and 'null' initializer +// CFA for 'let' and 'null' initializer function f3() { let x = null; if (cond) { @@ -38,19 +38,7 @@ function f3() { const y = x; // string | number | null } -// No CFA for 'let' with with type annotation -function f4() { - let x: any; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // any -} - -// CFA for 'var' with no type annotation and initializer +// CFA for 'var' with no initializer function f5() { var x; if (cond) { @@ -62,7 +50,7 @@ function f5() { const y = x; // string | number | undefined } -// CFA for 'var' with no type annotation and 'undefined' initializer +// CFA for 'var' with 'undefined' initializer function f6() { var x = undefined; if (cond) { @@ -74,7 +62,7 @@ function f6() { const y = x; // string | number | undefined } -// CFA for 'var' with no type annotation and 'null' initializer +// CFA for 'var' with 'null' initializer function f7() { var x = null; if (cond) { @@ -86,18 +74,6 @@ function f7() { const y = x; // string | number | null } -// No CFA for 'var' with with type annotation -function f8() { - var x: any; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // any -} - // No CFA for captured outer variables function f9() { let x; @@ -126,10 +102,12 @@ function f10() { const f = () => { const z = x; // any }; -} +} -//// [controlFlowLetVar.js] -// CFA for 'let' with no type annotation and initializer + +//// [out.js] +var cond = true; +// CFA for 'let' and no initializer function f1() { var x; if (cond) { @@ -140,7 +118,7 @@ function f1() { } var y = x; // string | number | undefined } -// CFA for 'let' with no type annotation and 'undefined' initializer +// CFA for 'let' and 'undefined' initializer function f2() { var x = undefined; if (cond) { @@ -151,7 +129,7 @@ function f2() { } var y = x; // string | number | undefined } -// CFA for 'let' with no type annotation and 'null' initializer +// CFA for 'let' and 'null' initializer function f3() { var x = null; if (cond) { @@ -162,18 +140,7 @@ function f3() { } var y = x; // string | number | null } -// No CFA for 'let' with with type annotation -function f4() { - var x; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - var y = x; // any -} -// CFA for 'var' with no type annotation and initializer +// CFA for 'var' with no initializer function f5() { var x; if (cond) { @@ -184,7 +151,7 @@ function f5() { } var y = x; // string | number | undefined } -// CFA for 'var' with no type annotation and 'undefined' initializer +// CFA for 'var' with 'undefined' initializer function f6() { var x = undefined; if (cond) { @@ -195,7 +162,7 @@ function f6() { } var y = x; // string | number | undefined } -// CFA for 'var' with no type annotation and 'null' initializer +// CFA for 'var' with 'null' initializer function f7() { var x = null; if (cond) { @@ -206,17 +173,6 @@ function f7() { } var y = x; // string | number | null } -// No CFA for 'var' with with type annotation -function f8() { - var x; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - var y = x; // any -} // No CFA for captured outer variables function f9() { var x; diff --git a/tests/baselines/reference/controlFlowJavascript.symbols b/tests/baselines/reference/controlFlowJavascript.symbols new file mode 100644 index 0000000000000..b3316de3b4e81 --- /dev/null +++ b/tests/baselines/reference/controlFlowJavascript.symbols @@ -0,0 +1,216 @@ +=== tests/cases/compiler/controlFlowJavascript.js === + +let cond = true; +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + +// CFA for 'let' and no initializer +function f1() { +>f1 : Symbol(f1, Decl(controlFlowJavascript.js, 1, 16)) + + let x; +>x : Symbol(x, Decl(controlFlowJavascript.js, 5, 7)) + + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = 1; +>x : Symbol(x, Decl(controlFlowJavascript.js, 5, 7)) + } + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = "hello"; +>x : Symbol(x, Decl(controlFlowJavascript.js, 5, 7)) + } + const y = x; // string | number | undefined +>y : Symbol(y, Decl(controlFlowJavascript.js, 12, 9)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 5, 7)) +} + +// CFA for 'let' and 'undefined' initializer +function f2() { +>f2 : Symbol(f2, Decl(controlFlowJavascript.js, 13, 1)) + + let x = undefined; +>x : Symbol(x, Decl(controlFlowJavascript.js, 17, 7)) +>undefined : Symbol(undefined) + + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = 1; +>x : Symbol(x, Decl(controlFlowJavascript.js, 17, 7)) + } + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = "hello"; +>x : Symbol(x, Decl(controlFlowJavascript.js, 17, 7)) + } + const y = x; // string | number | undefined +>y : Symbol(y, Decl(controlFlowJavascript.js, 24, 9)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 17, 7)) +} + +// CFA for 'let' and 'null' initializer +function f3() { +>f3 : Symbol(f3, Decl(controlFlowJavascript.js, 25, 1)) + + let x = null; +>x : Symbol(x, Decl(controlFlowJavascript.js, 29, 7)) + + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = 1; +>x : Symbol(x, Decl(controlFlowJavascript.js, 29, 7)) + } + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = "hello"; +>x : Symbol(x, Decl(controlFlowJavascript.js, 29, 7)) + } + const y = x; // string | number | null +>y : Symbol(y, Decl(controlFlowJavascript.js, 36, 9)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 29, 7)) +} + +// CFA for 'var' with no initializer +function f5() { +>f5 : Symbol(f5, Decl(controlFlowJavascript.js, 37, 1)) + + var x; +>x : Symbol(x, Decl(controlFlowJavascript.js, 41, 7)) + + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = 1; +>x : Symbol(x, Decl(controlFlowJavascript.js, 41, 7)) + } + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = "hello"; +>x : Symbol(x, Decl(controlFlowJavascript.js, 41, 7)) + } + const y = x; // string | number | undefined +>y : Symbol(y, Decl(controlFlowJavascript.js, 48, 9)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 41, 7)) +} + +// CFA for 'var' with 'undefined' initializer +function f6() { +>f6 : Symbol(f6, Decl(controlFlowJavascript.js, 49, 1)) + + var x = undefined; +>x : Symbol(x, Decl(controlFlowJavascript.js, 53, 7)) +>undefined : Symbol(undefined) + + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = 1; +>x : Symbol(x, Decl(controlFlowJavascript.js, 53, 7)) + } + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = "hello"; +>x : Symbol(x, Decl(controlFlowJavascript.js, 53, 7)) + } + const y = x; // string | number | undefined +>y : Symbol(y, Decl(controlFlowJavascript.js, 60, 9)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 53, 7)) +} + +// CFA for 'var' with 'null' initializer +function f7() { +>f7 : Symbol(f7, Decl(controlFlowJavascript.js, 61, 1)) + + var x = null; +>x : Symbol(x, Decl(controlFlowJavascript.js, 65, 7)) + + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = 1; +>x : Symbol(x, Decl(controlFlowJavascript.js, 65, 7)) + } + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = "hello"; +>x : Symbol(x, Decl(controlFlowJavascript.js, 65, 7)) + } + const y = x; // string | number | null +>y : Symbol(y, Decl(controlFlowJavascript.js, 72, 9)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 65, 7)) +} + +// No CFA for captured outer variables +function f9() { +>f9 : Symbol(f9, Decl(controlFlowJavascript.js, 73, 1)) + + let x; +>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7)) + + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = 1; +>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7)) + } + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = "hello"; +>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7)) + } + const y = x; // string | number | undefined +>y : Symbol(y, Decl(controlFlowJavascript.js, 84, 9)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7)) + + function f() { +>f : Symbol(f, Decl(controlFlowJavascript.js, 84, 16)) + + const z = x; // any +>z : Symbol(z, Decl(controlFlowJavascript.js, 86, 13)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7)) + } +} + +// No CFA for captured outer variables +function f10() { +>f10 : Symbol(f10, Decl(controlFlowJavascript.js, 88, 1)) + + let x; +>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7)) + + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = 1; +>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7)) + } + if (cond) { +>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3)) + + x = "hello"; +>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7)) + } + const y = x; // string | number | undefined +>y : Symbol(y, Decl(controlFlowJavascript.js, 99, 9)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7)) + + const f = () => { +>f : Symbol(f, Decl(controlFlowJavascript.js, 100, 9)) + + const z = x; // any +>z : Symbol(z, Decl(controlFlowJavascript.js, 101, 13)) +>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7)) + + }; +} + diff --git a/tests/baselines/reference/controlFlowLetVar.types b/tests/baselines/reference/controlFlowJavascript.types similarity index 59% rename from tests/baselines/reference/controlFlowLetVar.types rename to tests/baselines/reference/controlFlowJavascript.types index 09f0ea8348887..0b88c62cb785a 100644 --- a/tests/baselines/reference/controlFlowLetVar.types +++ b/tests/baselines/reference/controlFlowJavascript.types @@ -1,9 +1,10 @@ -=== tests/cases/compiler/controlFlowLetVar.ts === +=== tests/cases/compiler/controlFlowJavascript.js === -declare let cond: boolean; +let cond = true; >cond : boolean +>true : true -// CFA for 'let' with no type annotation and initializer +// CFA for 'let' and no initializer function f1() { >f1 : () => void @@ -27,11 +28,11 @@ function f1() { >"hello" : "hello" } const y = x; // string | number | undefined ->y : string | number | undefined ->x : string | number | undefined +>y : string | number +>x : string | number } -// CFA for 'let' with no type annotation and 'undefined' initializer +// CFA for 'let' and 'undefined' initializer function f2() { >f2 : () => void @@ -56,11 +57,11 @@ function f2() { >"hello" : "hello" } const y = x; // string | number | undefined ->y : string | number | undefined ->x : string | number | undefined +>y : string | number +>x : string | number } -// CFA for 'let' with no type annotation and 'null' initializer +// CFA for 'let' and 'null' initializer function f3() { >f3 : () => void @@ -85,39 +86,11 @@ function f3() { >"hello" : "hello" } const y = x; // string | number | null ->y : string | number | null ->x : string | number | null +>y : string | number +>x : string | number } -// No CFA for 'let' with with type annotation -function f4() { ->f4 : () => void - - let x: any; ->x : any - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // any ->y : any ->x : any -} - -// CFA for 'var' with no type annotation and initializer +// CFA for 'var' with no initializer function f5() { >f5 : () => void @@ -141,11 +114,11 @@ function f5() { >"hello" : "hello" } const y = x; // string | number | undefined ->y : string | number | undefined ->x : string | number | undefined +>y : string | number +>x : string | number } -// CFA for 'var' with no type annotation and 'undefined' initializer +// CFA for 'var' with 'undefined' initializer function f6() { >f6 : () => void @@ -170,11 +143,11 @@ function f6() { >"hello" : "hello" } const y = x; // string | number | undefined ->y : string | number | undefined ->x : string | number | undefined +>y : string | number +>x : string | number } -// CFA for 'var' with no type annotation and 'null' initializer +// CFA for 'var' with 'null' initializer function f7() { >f7 : () => void @@ -199,36 +172,8 @@ function f7() { >"hello" : "hello" } const y = x; // string | number | null ->y : string | number | null ->x : string | number | null -} - -// No CFA for 'var' with with type annotation -function f8() { ->f8 : () => void - - var x: any; ->x : any - - if (cond) { ->cond : boolean - - x = 1; ->x = 1 : 1 ->x : any ->1 : 1 - } - if (cond) { ->cond : boolean - - x = "hello"; ->x = "hello" : "hello" ->x : any ->"hello" : "hello" - } - const y = x; // any ->y : any ->x : any +>y : string | number +>x : string | number } // No CFA for captured outer variables @@ -255,8 +200,8 @@ function f9() { >"hello" : "hello" } const y = x; // string | number | undefined ->y : string | number | undefined ->x : string | number | undefined +>y : string | number +>x : string | number function f() { >f : () => void @@ -291,8 +236,8 @@ function f10() { >"hello" : "hello" } const y = x; // string | number | undefined ->y : string | number | undefined ->x : string | number | undefined +>y : string | number +>x : string | number const f = () => { >f : () => void @@ -304,3 +249,4 @@ function f10() { }; } + diff --git a/tests/baselines/reference/controlFlowLetVar.symbols b/tests/baselines/reference/controlFlowLetVar.symbols deleted file mode 100644 index f58edd781b780..0000000000000 --- a/tests/baselines/reference/controlFlowLetVar.symbols +++ /dev/null @@ -1,263 +0,0 @@ -=== tests/cases/compiler/controlFlowLetVar.ts === - -declare let cond: boolean; ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - -// CFA for 'let' with no type annotation and initializer -function f1() { ->f1 : Symbol(f1, Decl(controlFlowLetVar.ts, 1, 26)) - - let x; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowLetVar.ts, 12, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7)) -} - -// CFA for 'let' with no type annotation and 'undefined' initializer -function f2() { ->f2 : Symbol(f2, Decl(controlFlowLetVar.ts, 13, 1)) - - let x = undefined; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7)) ->undefined : Symbol(undefined) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowLetVar.ts, 24, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7)) -} - -// CFA for 'let' with no type annotation and 'null' initializer -function f3() { ->f3 : Symbol(f3, Decl(controlFlowLetVar.ts, 25, 1)) - - let x = null; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7)) - } - const y = x; // string | number | null ->y : Symbol(y, Decl(controlFlowLetVar.ts, 36, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7)) -} - -// No CFA for 'let' with with type annotation -function f4() { ->f4 : Symbol(f4, Decl(controlFlowLetVar.ts, 37, 1)) - - let x: any; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7)) - } - const y = x; // any ->y : Symbol(y, Decl(controlFlowLetVar.ts, 48, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7)) -} - -// CFA for 'var' with no type annotation and initializer -function f5() { ->f5 : Symbol(f5, Decl(controlFlowLetVar.ts, 49, 1)) - - var x; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowLetVar.ts, 60, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7)) -} - -// CFA for 'var' with no type annotation and 'undefined' initializer -function f6() { ->f6 : Symbol(f6, Decl(controlFlowLetVar.ts, 61, 1)) - - var x = undefined; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7)) ->undefined : Symbol(undefined) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowLetVar.ts, 72, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7)) -} - -// CFA for 'var' with no type annotation and 'null' initializer -function f7() { ->f7 : Symbol(f7, Decl(controlFlowLetVar.ts, 73, 1)) - - var x = null; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7)) - } - const y = x; // string | number | null ->y : Symbol(y, Decl(controlFlowLetVar.ts, 84, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7)) -} - -// No CFA for 'var' with with type annotation -function f8() { ->f8 : Symbol(f8, Decl(controlFlowLetVar.ts, 85, 1)) - - var x: any; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7)) - } - const y = x; // any ->y : Symbol(y, Decl(controlFlowLetVar.ts, 96, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7)) -} - -// No CFA for captured outer variables -function f9() { ->f9 : Symbol(f9, Decl(controlFlowLetVar.ts, 97, 1)) - - let x; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowLetVar.ts, 108, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7)) - - function f() { ->f : Symbol(f, Decl(controlFlowLetVar.ts, 108, 16)) - - const z = x; // any ->z : Symbol(z, Decl(controlFlowLetVar.ts, 110, 13)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7)) - } -} - -// No CFA for captured outer variables -function f10() { ->f10 : Symbol(f10, Decl(controlFlowLetVar.ts, 112, 1)) - - let x; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7)) - - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = 1; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7)) - } - if (cond) { ->cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11)) - - x = "hello"; ->x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7)) - } - const y = x; // string | number | undefined ->y : Symbol(y, Decl(controlFlowLetVar.ts, 123, 9)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7)) - - const f = () => { ->f : Symbol(f, Decl(controlFlowLetVar.ts, 124, 9)) - - const z = x; // any ->z : Symbol(z, Decl(controlFlowLetVar.ts, 125, 13)) ->x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7)) - - }; -} diff --git a/tests/baselines/reference/downlevelLetConst14.types b/tests/baselines/reference/downlevelLetConst14.types index 493c17b97cd01..29c87e76cce5c 100644 --- a/tests/baselines/reference/downlevelLetConst14.types +++ b/tests/baselines/reference/downlevelLetConst14.types @@ -77,22 +77,22 @@ use(x); use(z0); >use(z0) : any >use : (a: any) => any ->z0 : undefined +>z0 : any use(z1); >use(z1) : any >use : (a: any) => any ->z1 : undefined +>z1 : any use(z2); >use(z2) : any >use : (a: any) => any ->z2 : undefined +>z2 : any use(z3); >use(z3) : any >use : (a: any) => any ->z3 : undefined +>z3 : any var z6; >z6 : any @@ -149,7 +149,7 @@ use(y); use(z6); >use(z6) : any >use : (a: any) => any ->z6 : undefined +>z6 : any var z = false; >z : boolean diff --git a/tests/baselines/reference/downlevelLetConst15.types b/tests/baselines/reference/downlevelLetConst15.types index 6d224b6310d66..9e58c6488214a 100644 --- a/tests/baselines/reference/downlevelLetConst15.types +++ b/tests/baselines/reference/downlevelLetConst15.types @@ -83,22 +83,22 @@ use(x); use(z0); >use(z0) : any >use : (a: any) => any ->z0 : undefined +>z0 : any use(z1); >use(z1) : any >use : (a: any) => any ->z1 : undefined +>z1 : any use(z2); >use(z2) : any >use : (a: any) => any ->z2 : undefined +>z2 : any use(z3); >use(z3) : any >use : (a: any) => any ->z3 : undefined +>z3 : any var z6; >z6 : any @@ -155,7 +155,7 @@ use(y); use(z6); >use(z6) : any >use : (a: any) => any ->z6 : undefined +>z6 : any var z = false; >z : boolean diff --git a/tests/baselines/reference/forIn.errors.txt b/tests/baselines/reference/forIn.errors.txt index a7dd629698a02..ccc1423f1aa65 100644 --- a/tests/baselines/reference/forIn.errors.txt +++ b/tests/baselines/reference/forIn.errors.txt @@ -1,24 +1,17 @@ tests/cases/compiler/forIn.ts(2,10): error TS2404: The left-hand side of a 'for...in' statement cannot use a type annotation. -tests/cases/compiler/forIn.ts(2,22): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/compiler/forIn.ts(7,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/compiler/forIn.ts(18,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. tests/cases/compiler/forIn.ts(20,4): error TS2304: Cannot find name 'k'. -==== tests/cases/compiler/forIn.ts (5 errors) ==== +==== tests/cases/compiler/forIn.ts (2 errors) ==== var arr = null; for (var i:number in arr) { // error ~ !!! error TS2404: The left-hand side of a 'for...in' statement cannot use a type annotation. - ~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. var x1 = arr[i]; var y1 = arr[i]; } for (var j in arr) { // ok - ~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. var x2 = arr[j]; var y2 = arr[j]; } @@ -30,8 +23,6 @@ tests/cases/compiler/forIn.ts(20,4): error TS2304: Cannot find name 'k'. } for (var l in arr) { - ~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. // error in the body k[l] = 1; ~ diff --git a/tests/baselines/reference/initializePropertiesWithRenamedLet.types b/tests/baselines/reference/initializePropertiesWithRenamedLet.types index d6937da8983f8..65ea68059a7b9 100644 --- a/tests/baselines/reference/initializePropertiesWithRenamedLet.types +++ b/tests/baselines/reference/initializePropertiesWithRenamedLet.types @@ -10,15 +10,15 @@ if (true) { >x0 : any var obj1 = { x0: x0 }; ->obj1 : { x0: undefined; } ->{ x0: x0 } : { x0: undefined; } ->x0 : undefined ->x0 : undefined +>obj1 : { x0: any; } +>{ x0: x0 } : { x0: any; } +>x0 : any +>x0 : any var obj2 = { x0 }; ->obj2 : { x0: undefined; } ->{ x0 } : { x0: undefined; } ->x0 : undefined +>obj2 : { x0: any; } +>{ x0 } : { x0: any; } +>x0 : any } var x, y, z; diff --git a/tests/baselines/reference/json.stringify.types b/tests/baselines/reference/json.stringify.types index 8ff84885d9c33..b063b06d8d07c 100644 --- a/tests/baselines/reference/json.stringify.types +++ b/tests/baselines/reference/json.stringify.types @@ -1,7 +1,7 @@ === tests/cases/compiler/json.stringify.ts === var value = null; ->value : any +>value : null >null : null JSON.stringify(value, undefined, 2); diff --git a/tests/baselines/reference/localClassesInLoop.types b/tests/baselines/reference/localClassesInLoop.types index 8805044589807..c88bfc0435d0c 100644 --- a/tests/baselines/reference/localClassesInLoop.types +++ b/tests/baselines/reference/localClassesInLoop.types @@ -35,12 +35,12 @@ use(data[0]() === data[1]()); >use(data[0]() === data[1]()) : any >use : (a: any) => any >data[0]() === data[1]() : boolean ->data[0]() : typeof C ->data[0] : () => typeof C ->data : (() => typeof C)[] +>data[0]() : any +>data[0] : any +>data : any[] >0 : 0 ->data[1]() : typeof C ->data[1] : () => typeof C ->data : (() => typeof C)[] +>data[1]() : any +>data[1] : any +>data : any[] >1 : 1 diff --git a/tests/baselines/reference/localClassesInLoop_ES6.types b/tests/baselines/reference/localClassesInLoop_ES6.types index 390f4b8b1ddb2..9d487f6c60051 100644 --- a/tests/baselines/reference/localClassesInLoop_ES6.types +++ b/tests/baselines/reference/localClassesInLoop_ES6.types @@ -36,12 +36,12 @@ use(data[0]() === data[1]()); >use(data[0]() === data[1]()) : any >use : (a: any) => any >data[0]() === data[1]() : boolean ->data[0]() : typeof C ->data[0] : () => typeof C ->data : (() => typeof C)[] +>data[0]() : any +>data[0] : any +>data : any[] >0 : 0 ->data[1]() : typeof C ->data[1] : () => typeof C ->data : (() => typeof C)[] +>data[1]() : any +>data[1] : any +>data : any[] >1 : 1 diff --git a/tests/baselines/reference/nestedBlockScopedBindings3.types b/tests/baselines/reference/nestedBlockScopedBindings3.types index ca13759bac4f2..0de8123861d5b 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings3.types +++ b/tests/baselines/reference/nestedBlockScopedBindings3.types @@ -31,7 +31,7 @@ function a1() { for (let x; x < 1;) { >x : any >x < 1 : boolean ->x : undefined +>x : any >1 : 1 () => x; @@ -53,24 +53,24 @@ function a2() { for (let x; x < 1;) { >x : any >x < 1 : boolean ->x : number +>x : any >1 : 1 x = x + 1; ->x = x + 1 : number +>x = x + 1 : any +>x : any +>x + 1 : any >x : any ->x + 1 : number ->x : number >1 : 1 } for (let x;;) { >x : any x = x + 2; ->x = x + 2 : number +>x = x + 2 : any +>x : any +>x + 2 : any >x : any ->x + 2 : number ->x : number >2 : 2 } } @@ -82,14 +82,14 @@ function a3() { for (let x; x < 1;) { >x : any >x < 1 : boolean ->x : number +>x : any >1 : 1 x = x + 1; ->x = x + 1 : number +>x = x + 1 : any +>x : any +>x + 1 : any >x : any ->x + 1 : number ->x : number >1 : 1 } switch (1) { @@ -111,14 +111,14 @@ function a4() { for (let x; x < 1;) { >x : any >x < 1 : boolean ->x : number +>x : any >1 : 1 x = x + 1; ->x = x + 1 : number +>x = x + 1 : any +>x : any +>x + 1 : any >x : any ->x + 1 : number ->x : number >1 : 1 () => x; @@ -145,14 +145,14 @@ function a5() { for (let x; x < 1;) { >x : any >x < 1 : boolean ->x : number +>x : any >1 : 1 x = x + 1; ->x = x + 1 : number +>x = x + 1 : any +>x : any +>x + 1 : any >x : any ->x + 1 : number ->x : number >1 : 1 () => x; diff --git a/tests/baselines/reference/nestedBlockScopedBindings4.types b/tests/baselines/reference/nestedBlockScopedBindings4.types index 9e0147f25f7fb..65b5d73db9d85 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings4.types +++ b/tests/baselines/reference/nestedBlockScopedBindings4.types @@ -5,24 +5,24 @@ function a0() { for (let x; x < 1;) { >x : any >x < 1 : boolean ->x : number +>x : any >1 : 1 x = x + 1; ->x = x + 1 : number +>x = x + 1 : any +>x : any +>x + 1 : any >x : any ->x + 1 : number ->x : number >1 : 1 } for (let x;;) { >x : any x = x + 2; ->x = x + 2 : number +>x = x + 2 : any +>x : any +>x + 2 : any >x : any ->x + 2 : number ->x : number >2 : 2 } } @@ -33,14 +33,14 @@ function a1() { for (let x; x < 1;) { >x : any >x < 1 : boolean ->x : number +>x : any >1 : 1 x = x + 1; ->x = x + 1 : number +>x = x + 1 : any +>x : any +>x + 1 : any >x : any ->x + 1 : number ->x : number >1 : 1 () => x; @@ -51,10 +51,10 @@ function a1() { >x : any x = x + 2; ->x = x + 2 : number +>x = x + 2 : any +>x : any +>x + 2 : any >x : any ->x + 2 : number ->x : number >2 : 2 } } @@ -65,24 +65,24 @@ function a2() { for (let x; x < 1;) { >x : any >x < 1 : boolean ->x : number +>x : any >1 : 1 x = x + 1; ->x = x + 1 : number +>x = x + 1 : any +>x : any +>x + 1 : any >x : any ->x + 1 : number ->x : number >1 : 1 } for (let x;;) { >x : any x = x + 2; ->x = x + 2 : number +>x = x + 2 : any +>x : any +>x + 2 : any >x : any ->x + 2 : number ->x : number >2 : 2 () => x; @@ -98,14 +98,14 @@ function a3() { for (let x; x < 1;) { >x : any >x < 1 : boolean ->x : number +>x : any >1 : 1 x = x + 1; ->x = x + 1 : number +>x = x + 1 : any +>x : any +>x + 1 : any >x : any ->x + 1 : number ->x : number >1 : 1 () => x; @@ -116,10 +116,10 @@ function a3() { >x : any x = x + 2; ->x = x + 2 : number +>x = x + 2 : any +>x : any +>x + 2 : any >x : any ->x + 2 : number ->x : number >2 : 2 () => x; diff --git a/tests/baselines/reference/nestedBlockScopedBindings6.types b/tests/baselines/reference/nestedBlockScopedBindings6.types index bf38f46d50804..865dea31e377e 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings6.types +++ b/tests/baselines/reference/nestedBlockScopedBindings6.types @@ -18,10 +18,10 @@ function a0() { >x : any x = x + 2; ->x = x + 2 : number +>x = x + 2 : any +>x : any +>x + 2 : any >x : any ->x + 2 : number ->x : number >2 : 2 } } @@ -49,10 +49,10 @@ function a1() { >x : any x = x + 2; ->x = x + 2 : number +>x = x + 2 : any +>x : any +>x + 2 : any >x : any ->x + 2 : number ->x : number >2 : 2 } } @@ -76,10 +76,10 @@ function a2() { >x : any x = x + 2; ->x = x + 2 : number +>x = x + 2 : any +>x : any +>x + 2 : any >x : any ->x + 2 : number ->x : number >2 : 2 () => x; @@ -111,10 +111,10 @@ function a3() { >x : any x = x + 2; ->x = x + 2 : number +>x = x + 2 : any +>x : any +>x + 2 : any >x : any ->x + 2 : number ->x : number >2 : 2 () => x; diff --git a/tests/baselines/reference/null.types b/tests/baselines/reference/null.types index ab5ae728dea39..35c084c3cbf40 100644 --- a/tests/baselines/reference/null.types +++ b/tests/baselines/reference/null.types @@ -5,10 +5,10 @@ var x=null; >null : null var y=3+x; ->y : number ->3+x : number +>y : any +>3+x : any >3 : 3 ->x : null +>x : any var z=3+null; >z : number diff --git a/tests/baselines/reference/objectLiteralShorthandProperties.types b/tests/baselines/reference/objectLiteralShorthandProperties.types index 168fcc07af784..4f4482906aa50 100644 --- a/tests/baselines/reference/objectLiteralShorthandProperties.types +++ b/tests/baselines/reference/objectLiteralShorthandProperties.types @@ -5,35 +5,35 @@ var a, b, c; >c : any var x1 = { ->x1 : { a: undefined; } ->{ a} : { a: undefined; } +>x1 : { a: any; } +>{ a} : { a: any; } a ->a : undefined +>a : any }; var x2 = { ->x2 : { a: undefined; } ->{ a,} : { a: undefined; } +>x2 : { a: any; } +>{ a,} : { a: any; } a, ->a : undefined +>a : any } var x3 = { >x3 : any ->{ a: 0, b, c, d() { }, x3, parent: x3} : { a: number; b: undefined; c: undefined; d(): void; x3: any; parent: any; } +>{ a: 0, b, c, d() { }, x3, parent: x3} : { a: number; b: any; c: any; d(): void; x3: any; parent: any; } a: 0, >a : number >0 : 0 b, ->b : undefined +>b : any c, ->c : undefined +>c : any d() { }, >d : () => void diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types b/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types index 80cbe304040b9..1565be04625b3 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types @@ -5,35 +5,35 @@ var a, b, c; >c : any var x1 = { ->x1 : { a: undefined; } ->{ a} : { a: undefined; } +>x1 : { a: any; } +>{ a} : { a: any; } a ->a : undefined +>a : any }; var x2 = { ->x2 : { a: undefined; } ->{ a,} : { a: undefined; } +>x2 : { a: any; } +>{ a,} : { a: any; } a, ->a : undefined +>a : any } var x3 = { >x3 : any ->{ a: 0, b, c, d() { }, x3, parent: x3} : { a: number; b: undefined; c: undefined; d(): void; x3: any; parent: any; } +>{ a: 0, b, c, d() { }, x3, parent: x3} : { a: number; b: any; c: any; d(): void; x3: any; parent: any; } a: 0, >a : number >0 : 0 b, ->b : undefined +>b : any c, ->c : undefined +>c : any d() { }, >d : () => void diff --git a/tests/baselines/reference/objectSpreadNoTransform.types b/tests/baselines/reference/objectSpreadNoTransform.types index ae89a3a7993e3..c7cfdf8f00606 100644 --- a/tests/baselines/reference/objectSpreadNoTransform.types +++ b/tests/baselines/reference/objectSpreadNoTransform.types @@ -25,6 +25,6 @@ var rest; >{ b, ...rest } = o : { a: string; b: string; x: number; } >{ b, ...rest } : any >b : any ->rest : undefined +>rest : any >o : { a: string; b: string; x: number; } diff --git a/tests/baselines/reference/parserAmbiguityWithBinaryOperator1.types b/tests/baselines/reference/parserAmbiguityWithBinaryOperator1.types index ca7d65c9c3495..234375fb46dda 100644 --- a/tests/baselines/reference/parserAmbiguityWithBinaryOperator1.types +++ b/tests/baselines/reference/parserAmbiguityWithBinaryOperator1.types @@ -10,12 +10,12 @@ function f1() { if (a < b || b > (c + 1)) { } >a < b || b > (c + 1) : boolean >a < b : boolean ->a : undefined ->b : undefined +>a : any +>b : any >b > (c + 1) : boolean ->b : undefined ->(c + 1) : number ->c + 1 : number ->c : undefined +>b : any +>(c + 1) : any +>c + 1 : any +>c : any >1 : 1 } diff --git a/tests/baselines/reference/parserAmbiguityWithBinaryOperator2.types b/tests/baselines/reference/parserAmbiguityWithBinaryOperator2.types index f4c1c2ac69080..ed3b4b903bb86 100644 --- a/tests/baselines/reference/parserAmbiguityWithBinaryOperator2.types +++ b/tests/baselines/reference/parserAmbiguityWithBinaryOperator2.types @@ -10,12 +10,12 @@ function f() { if (a < b && b > (c + 1)) { } >a < b && b > (c + 1) : boolean >a < b : boolean ->a : undefined ->b : undefined +>a : any +>b : any >b > (c + 1) : boolean ->b : undefined ->(c + 1) : number ->c + 1 : number ->c : undefined +>b : any +>(c + 1) : any +>c + 1 : any +>c : any >1 : 1 } diff --git a/tests/baselines/reference/parserAmbiguityWithBinaryOperator3.types b/tests/baselines/reference/parserAmbiguityWithBinaryOperator3.types index b112965634236..61601d8bdf653 100644 --- a/tests/baselines/reference/parserAmbiguityWithBinaryOperator3.types +++ b/tests/baselines/reference/parserAmbiguityWithBinaryOperator3.types @@ -10,13 +10,13 @@ function f() { if (a < b && b < (c + 1)) { } >a < b && b < (c + 1) : boolean >a < b : boolean ->a : undefined ->b : undefined +>a : any +>b : any >b < (c + 1) : boolean ->b : undefined ->(c + 1) : number ->c + 1 : number ->c : undefined +>b : any +>(c + 1) : any +>c + 1 : any +>c : any >1 : 1 } diff --git a/tests/baselines/reference/parserForStatement2.errors.txt b/tests/baselines/reference/parserForStatement2.errors.txt index 68ab999b657a5..59d6dd6dec8f4 100644 --- a/tests/baselines/reference/parserForStatement2.errors.txt +++ b/tests/baselines/reference/parserForStatement2.errors.txt @@ -1,17 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts(4,13): error TS2538: Type 'undefined' cannot be used as an index type. -tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts(4,20): error TS2538: Type 'undefined' cannot be used as an index type. tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts(4,30): error TS2304: Cannot find name 'd'. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts (3 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement2.ts (1 errors) ==== var a; var b = []; var c; for (a in b[c] = b[c] || [], d) { - ~ -!!! error TS2538: Type 'undefined' cannot be used as an index type. - ~ -!!! error TS2538: Type 'undefined' cannot be used as an index type. ~ !!! error TS2304: Cannot find name 'd'. diff --git a/tests/baselines/reference/parserharness.errors.txt b/tests/baselines/reference/parserharness.errors.txt index 90ac8e0e76027..d3d0c4056a1d5 100644 --- a/tests/baselines/reference/parserharness.errors.txt +++ b/tests/baselines/reference/parserharness.errors.txt @@ -25,9 +25,6 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(776,42): e tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(781,23): error TS2503: Cannot find namespace 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(794,49): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(795,49): error TS2304: Cannot find name 'TypeScript'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(820,31): error TS2339: Property 'length' does not exist on type 'null'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(976,28): error TS2339: Property 'length' does not exist on type 'null'. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(977,82): error TS2339: Property 'join' does not exist on type 'null'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,53): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,89): error TS2304: Cannot find name 'TypeScript'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(987,115): error TS2503: Cannot find namespace 'TypeScript'. @@ -113,7 +110,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1787,68): tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): error TS2304: Cannot find name 'Diff'. -==== tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts (113 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts (110 errors) ==== // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -988,8 +985,6 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): }) return errors.length === 0; - ~~~~~~ -!!! error TS2339: Property 'length' does not exist on type 'null'. } public isSubtypeOf(other: Type) { @@ -1146,11 +1141,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): }) if (errors.length > 0) - ~~~~~~ -!!! error TS2339: Property 'length' does not exist on type 'null'. throw new Error("Type definition contains errors: " + errors.join(",")); - ~~~~ -!!! error TS2339: Property 'join' does not exist on type 'null'. var matchingIdentifiers: Type[] = []; diff --git a/tests/baselines/reference/protoAsIndexInIndexExpression.types b/tests/baselines/reference/protoAsIndexInIndexExpression.types index 6d1374d1f78f7..b761aa2c7a70a 100644 --- a/tests/baselines/reference/protoAsIndexInIndexExpression.types +++ b/tests/baselines/reference/protoAsIndexInIndexExpression.types @@ -14,11 +14,11 @@ var WorkspacePrototype = { } }; WorkspacePrototype['__proto__'] = EntityPrototype; ->WorkspacePrototype['__proto__'] = EntityPrototype : undefined +>WorkspacePrototype['__proto__'] = EntityPrototype : any >WorkspacePrototype['__proto__'] : any >WorkspacePrototype : { serialize: () => any; } >'__proto__' : "___proto__" ->EntityPrototype : undefined +>EntityPrototype : any var o = { >o : { "__proto__": number; } diff --git a/tests/baselines/reference/strictNullChecksNoWidening.types b/tests/baselines/reference/strictNullChecksNoWidening.types index e24797850ee2b..a544f9cef94a4 100644 --- a/tests/baselines/reference/strictNullChecksNoWidening.types +++ b/tests/baselines/reference/strictNullChecksNoWidening.types @@ -1,11 +1,11 @@ === tests/cases/conformance/types/typeRelationships/widenedTypes/strictNullChecksNoWidening.ts === var a1 = null; ->a1 : any +>a1 : null >null : null var a2 = undefined; ->a2 : any +>a2 : undefined >undefined : undefined var a3 = void 0; @@ -14,7 +14,7 @@ var a3 = void 0; >0 : 0 var b1 = []; ->b1 : any[] +>b1 : never[] >[] : never[] var b2 = [,]; diff --git a/tests/baselines/reference/tsxEmit1.types b/tests/baselines/reference/tsxEmit1.types index c3ca7a2b1b015..84f00b4758ab6 100644 --- a/tests/baselines/reference/tsxEmit1.types +++ b/tests/baselines/reference/tsxEmit1.types @@ -61,7 +61,7 @@ var selfClosed7 =
; >
: JSX.Element >div : any >x : any ->p : undefined +>p : any >y : any var openClosed1 =
; @@ -82,7 +82,7 @@ var openClosed3 =
{p}
; >
{p}
: JSX.Element >div : any >n : any ->p : undefined +>p : any >div : any var openClosed4 =
{p < p}
; @@ -91,8 +91,8 @@ var openClosed4 =
{p < p}
; >div : any >n : any >p < p : boolean ->p : undefined ->p : undefined +>p : any +>p : any >div : any var openClosed5 =
{p > p}
; @@ -101,8 +101,8 @@ var openClosed5 =
{p > p}
; >div : any >n : any >p > p : boolean ->p : undefined ->p : undefined +>p : any +>p : any >div : any class SomeClass { @@ -180,7 +180,7 @@ var whitespace2 =
{p}
; >whitespace2 : JSX.Element >
{p}
: JSX.Element >div : any ->p : undefined +>p : any >div : any var whitespace3 =
@@ -189,7 +189,7 @@ var whitespace3 =
>div : any {p} ->p : undefined +>p : any
; >div : any diff --git a/tests/baselines/reference/tsxEmit2.types b/tests/baselines/reference/tsxEmit2.types index d306dc9ffe057..5b267d8b80262 100644 --- a/tests/baselines/reference/tsxEmit2.types +++ b/tests/baselines/reference/tsxEmit2.types @@ -22,16 +22,16 @@ var spreads1 =
{p2}
; >spreads1 : JSX.Element >
{p2}
: JSX.Element >div : any ->p1 : undefined ->p2 : undefined +>p1 : any +>p2 : any >div : any var spreads2 =
{p2}
; >spreads2 : JSX.Element >
{p2}
: JSX.Element >div : any ->p1 : undefined ->p2 : undefined +>p1 : any +>p2 : any >div : any var spreads3 =
{p2}
; @@ -39,19 +39,19 @@ var spreads3 =
{p2}
; >
{p2}
: JSX.Element >div : any >x : any ->p3 : undefined ->p1 : undefined ->p2 : undefined +>p3 : any +>p1 : any +>p2 : any >div : any var spreads4 =
{p2}
; >spreads4 : JSX.Element >
{p2}
: JSX.Element >div : any ->p1 : undefined +>p1 : any >x : any ->p3 : undefined ->p2 : undefined +>p3 : any +>p2 : any >div : any var spreads5 =
{p2}
; @@ -59,10 +59,10 @@ var spreads5 =
{p2}
; >
{p2}
: JSX.Element >div : any >x : any ->p2 : undefined ->p1 : undefined +>p2 : any +>p1 : any >y : any ->p3 : undefined ->p2 : undefined +>p3 : any +>p2 : any >div : any diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index b2cb2f73eba05..8eb14e9196365 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -63,7 +63,7 @@ var selfClosed7 =
; >
: JSX.Element >div : any >x : any ->p : undefined +>p : any >y : any >b : any @@ -85,7 +85,7 @@ var openClosed3 =
{p}
; >
{p}
: JSX.Element >div : any >n : any ->p : undefined +>p : any >div : any var openClosed4 =
{p < p}
; @@ -94,8 +94,8 @@ var openClosed4 =
{p < p}
; >div : any >n : any >p < p : boolean ->p : undefined ->p : undefined +>p : any +>p : any >div : any var openClosed5 =
{p > p}
; @@ -105,8 +105,8 @@ var openClosed5 =
{p > p}
; >n : any >b : any >p > p : boolean ->p : undefined ->p : undefined +>p : any +>p : any >div : any class SomeClass { @@ -184,7 +184,7 @@ var whitespace2 =
{p}
; >whitespace2 : JSX.Element >
{p}
: JSX.Element >div : any ->p : undefined +>p : any >div : any var whitespace3 =
@@ -193,7 +193,7 @@ var whitespace3 =
>div : any {p} ->p : undefined +>p : any
; >div : any diff --git a/tests/baselines/reference/tsxReactEmit2.types b/tests/baselines/reference/tsxReactEmit2.types index b05764e996fc3..928eeecadfac9 100644 --- a/tests/baselines/reference/tsxReactEmit2.types +++ b/tests/baselines/reference/tsxReactEmit2.types @@ -24,16 +24,16 @@ var spreads1 =
{p2}
; >spreads1 : JSX.Element >
{p2}
: JSX.Element >div : any ->p1 : undefined ->p2 : undefined +>p1 : any +>p2 : any >div : any var spreads2 =
{p2}
; >spreads2 : JSX.Element >
{p2}
: JSX.Element >div : any ->p1 : undefined ->p2 : undefined +>p1 : any +>p2 : any >div : any var spreads3 =
{p2}
; @@ -41,19 +41,19 @@ var spreads3 =
{p2}
; >
{p2}
: JSX.Element >div : any >x : any ->p3 : undefined ->p1 : undefined ->p2 : undefined +>p3 : any +>p1 : any +>p2 : any >div : any var spreads4 =
{p2}
; >spreads4 : JSX.Element >
{p2}
: JSX.Element >div : any ->p1 : undefined +>p1 : any >x : any ->p3 : undefined ->p2 : undefined +>p3 : any +>p2 : any >div : any var spreads5 =
{p2}
; @@ -61,10 +61,10 @@ var spreads5 =
{p2}
; >
{p2}
: JSX.Element >div : any >x : any ->p2 : undefined ->p1 : undefined +>p2 : any +>p1 : any >y : any ->p3 : undefined ->p2 : undefined +>p3 : any +>p2 : any >div : any diff --git a/tests/baselines/reference/tsxReactEmit5.types b/tests/baselines/reference/tsxReactEmit5.types index 73e7e6ff3913e..fb1c6594f3035 100644 --- a/tests/baselines/reference/tsxReactEmit5.types +++ b/tests/baselines/reference/tsxReactEmit5.types @@ -32,6 +32,6 @@ var spread1 =
; >
: JSX.Element >div : any >x : any ->foo : undefined +>foo : any >y : any diff --git a/tests/baselines/reference/tsxReactEmit6.types b/tests/baselines/reference/tsxReactEmit6.types index ae56de052cc44..b8a307eb9d765 100644 --- a/tests/baselines/reference/tsxReactEmit6.types +++ b/tests/baselines/reference/tsxReactEmit6.types @@ -35,7 +35,7 @@ namespace M { >
: JSX.Element >div : any >x : any ->foo : undefined +>foo : any >y : any // Quotes diff --git a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.errors.txt b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.errors.txt deleted file mode 100644 index 3f8cdf56c3dbc..0000000000000 --- a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/compiler/file1.ts(3,12): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. - - -==== tests/cases/compiler/file2.ts (0 errors) ==== - import f = require('./file1'); - f.foo(); - -==== tests/cases/compiler/file1.ts (1 errors) ==== - export function foo() { - var classes = undefined; - return new classes(null); - ~~~~~~~~~~~~~~~~~ -!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. - } - \ No newline at end of file diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index cd2103f646122..444d6a74e4303 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -1,7 +1,7 @@ === tests/cases/compiler/typedArrays.ts === function CreateTypedArrayTypes() { ->CreateTypedArrayTypes : () => (Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | Uint8ClampedArrayConstructor)[] +>CreateTypedArrayTypes : () => any[] var typedArrays = []; >typedArrays : any[] @@ -71,11 +71,11 @@ function CreateTypedArrayTypes() { >Uint8ClampedArray : Uint8ClampedArrayConstructor return typedArrays; ->typedArrays : (Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | Uint8ClampedArrayConstructor)[] +>typedArrays : any[] } function CreateTypedArrayInstancesFromLength(obj: number) { ->CreateTypedArrayInstancesFromLength : (obj: number) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>CreateTypedArrayInstancesFromLength : (obj: number) => any[] >obj : number var typedArrays = []; @@ -164,11 +164,11 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >obj : number return typedArrays; ->typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>typedArrays : any[] } function CreateTypedArrayInstancesFromArray(obj: number[]) { ->CreateTypedArrayInstancesFromArray : (obj: number[]) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>CreateTypedArrayInstancesFromArray : (obj: number[]) => any[] >obj : number[] var typedArrays = []; @@ -257,11 +257,11 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >obj : number[] return typedArrays; ->typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>typedArrays : any[] } function CreateIntegerTypedArraysFromArray2(obj:number[]) { ->CreateIntegerTypedArraysFromArray2 : (obj: number[]) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>CreateIntegerTypedArraysFromArray2 : (obj: number[]) => any[] >obj : number[] var typedArrays = []; @@ -368,11 +368,11 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >obj : number[] return typedArrays; ->typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>typedArrays : any[] } function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { ->CreateIntegerTypedArraysFromArrayLike : (obj: ArrayLike) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>CreateIntegerTypedArraysFromArrayLike : (obj: ArrayLike) => any[] >obj : ArrayLike >ArrayLike : ArrayLike @@ -480,11 +480,11 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >obj : ArrayLike return typedArrays; ->typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>typedArrays : any[] } function CreateTypedArraysOf(obj) { ->CreateTypedArraysOf : (obj: any) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>CreateTypedArraysOf : (obj: any) => any[] >obj : any var typedArrays = []; @@ -600,11 +600,11 @@ function CreateTypedArraysOf(obj) { >obj : any return typedArrays; ->typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>typedArrays : any[] } function CreateTypedArraysOf2() { ->CreateTypedArraysOf2 : () => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>CreateTypedArraysOf2 : () => any[] var typedArrays = []; >typedArrays : any[] @@ -737,11 +737,11 @@ function CreateTypedArraysOf2() { >4 : 4 return typedArrays; ->typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>typedArrays : any[] } function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { ->CreateTypedArraysFromMapFn : (obj: ArrayLike, mapFn: (n: number, v: number) => number) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>CreateTypedArraysFromMapFn : (obj: ArrayLike, mapFn: (n: number, v: number) => number) => any[] >obj : ArrayLike >ArrayLike : ArrayLike >mapFn : (n: number, v: number) => number @@ -861,11 +861,11 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >mapFn : (n: number, v: number) => number return typedArrays; ->typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>typedArrays : any[] } function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { ->CreateTypedArraysFromThisObj : (obj: ArrayLike, mapFn: (n: number, v: number) => number, thisArg: {}) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>CreateTypedArraysFromThisObj : (obj: ArrayLike, mapFn: (n: number, v: number) => number, thisArg: {}) => any[] >obj : ArrayLike >ArrayLike : ArrayLike >mapFn : (n: number, v: number) => number @@ -995,5 +995,5 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >thisArg : {} return typedArrays; ->typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] +>typedArrays : any[] } diff --git a/tests/baselines/reference/unusedSwitchStatment.errors.txt b/tests/baselines/reference/unusedSwitchStatment.errors.txt index 591e9deca7a21..a22c252f60d52 100644 --- a/tests/baselines/reference/unusedSwitchStatment.errors.txt +++ b/tests/baselines/reference/unusedSwitchStatment.errors.txt @@ -4,10 +4,9 @@ tests/cases/compiler/unusedSwitchStatment.ts(7,15): error TS6133: 'c' is declare tests/cases/compiler/unusedSwitchStatment.ts(10,13): error TS6133: 'z' is declared but never used. tests/cases/compiler/unusedSwitchStatment.ts(15,10): error TS2678: Type '0' is not comparable to type '2'. tests/cases/compiler/unusedSwitchStatment.ts(17,10): error TS2678: Type '1' is not comparable to type '2'. -tests/cases/compiler/unusedSwitchStatment.ts(18,9): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -==== tests/cases/compiler/unusedSwitchStatment.ts (7 errors) ==== +==== tests/cases/compiler/unusedSwitchStatment.ts (6 errors) ==== switch (1) { case 0: @@ -38,6 +37,4 @@ tests/cases/compiler/unusedSwitchStatment.ts(18,9): error TS2356: An arithmetic ~ !!! error TS2678: Type '1' is not comparable to type '2'. x++; - ~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. } \ No newline at end of file diff --git a/tests/cases/compiler/controlFlowLetVar.ts b/tests/cases/compiler/controlFlowJavascript.ts similarity index 61% rename from tests/cases/compiler/controlFlowLetVar.ts rename to tests/cases/compiler/controlFlowJavascript.ts index a56a3382642de..b2886a2233a99 100644 --- a/tests/cases/compiler/controlFlowLetVar.ts +++ b/tests/cases/compiler/controlFlowJavascript.ts @@ -1,8 +1,10 @@ -// @strictNullChecks: true +// @allowJs: true +// @Filename: controlFlowJavascript.js +// @out: out.js -declare let cond: boolean; +let cond = true; -// CFA for 'let' with no type annotation and initializer +// CFA for 'let' and no initializer function f1() { let x; if (cond) { @@ -14,7 +16,7 @@ function f1() { const y = x; // string | number | undefined } -// CFA for 'let' with no type annotation and 'undefined' initializer +// CFA for 'let' and 'undefined' initializer function f2() { let x = undefined; if (cond) { @@ -26,7 +28,7 @@ function f2() { const y = x; // string | number | undefined } -// CFA for 'let' with no type annotation and 'null' initializer +// CFA for 'let' and 'null' initializer function f3() { let x = null; if (cond) { @@ -38,19 +40,7 @@ function f3() { const y = x; // string | number | null } -// No CFA for 'let' with with type annotation -function f4() { - let x: any; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // any -} - -// CFA for 'var' with no type annotation and initializer +// CFA for 'var' with no initializer function f5() { var x; if (cond) { @@ -62,7 +52,7 @@ function f5() { const y = x; // string | number | undefined } -// CFA for 'var' with no type annotation and 'undefined' initializer +// CFA for 'var' with 'undefined' initializer function f6() { var x = undefined; if (cond) { @@ -74,7 +64,7 @@ function f6() { const y = x; // string | number | undefined } -// CFA for 'var' with no type annotation and 'null' initializer +// CFA for 'var' with 'null' initializer function f7() { var x = null; if (cond) { @@ -86,18 +76,6 @@ function f7() { const y = x; // string | number | null } -// No CFA for 'var' with with type annotation -function f8() { - var x: any; - if (cond) { - x = 1; - } - if (cond) { - x = "hello"; - } - const y = x; // any -} - // No CFA for captured outer variables function f9() { let x; @@ -126,4 +104,4 @@ function f10() { const f = () => { const z = x; // any }; -} \ No newline at end of file +}