From f9eddcebc8cbfe0e37e7abbfe042bec5aa33062a Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Tue, 26 Jan 2016 13:43:53 -0700 Subject: [PATCH 001/102] Update Array.concat type signature to fix #6594 --- src/lib/core.d.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index dbd4d37ef96..05da0e8057a 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -1011,12 +1011,7 @@ interface Array { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; + concat(...items: (T | T[])[]): T[]; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. From bcf22157d8934ca31836a75c6c00e8ddb78125b8 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Fri, 29 Jan 2016 18:20:05 -0800 Subject: [PATCH 002/102] Fix lastEncodedSourceMapSpan from being set to undefined --- src/compiler/sourcemap.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 8abf1432b0c..86bad38cb6e 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -16,6 +16,14 @@ namespace ts { } let nullSourceMapWriter: SourceMapWriter; + // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans + const defaultLastEncodedSourceMapSpan: SourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; export function getNullSourceMapWriter(): SourceMapWriter { if (nullSourceMapWriter === undefined) { @@ -79,13 +87,7 @@ namespace ts { // Last recorded and encoded spans lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; + lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; lastEncodedNameIndex = 0; // Initialize source map data @@ -159,10 +161,12 @@ namespace ts { // Pop sourceMapDecodedMappings to remove last entry sourceMapData.sourceMapDecodedMappings.pop(); - // Change the last encoded source map + // Point the lastEncodedSourceMapSpace to the previous encoded sourceMapSpan + // If the list is empty which indicates that we are at the beginning of the file, + // we have to reset it to default value (same value when we first initialize sourceMapWriter) lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - undefined; + defaultLastEncodedSourceMapSpan; // TODO: Update lastEncodedNameIndex // Since we dont support this any more, lets not worry about it right now. From 8ce886c4369e0289a61a2a261308e3e2e5872c5e Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Fri, 29 Jan 2016 18:20:17 -0800 Subject: [PATCH 003/102] Update baselines --- ...ationDestructuringObjectBindingPattern1.js | 7 +++ ...nDestructuringObjectBindingPattern1.js.map | 2 + ...cturingObjectBindingPattern1.sourcemap.txt | 24 +++++++++ ...DestructuringObjectBindingPattern1.symbols | 6 +++ ...onDestructuringObjectBindingPattern1.types | 8 +++ ...ationDestructuringObjectBindingPattern2.js | 9 ++++ ...nDestructuringObjectBindingPattern2.js.map | 2 + ...cturingObjectBindingPattern2.sourcemap.txt | 52 +++++++++++++++++++ ...DestructuringObjectBindingPattern2.symbols | 12 +++++ ...onDestructuringObjectBindingPattern2.types | 17 ++++++ 10 files changed, 139 insertions(+) create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.types create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.types diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js new file mode 100644 index 00000000000..c4e56eefe1e --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js @@ -0,0 +1,7 @@ +//// [sourceMapValidationDestructuringObjectBindingPattern1.ts] + +var {x} = { x: 20 }; + +//// [sourceMapValidationDestructuringObjectBindingPattern1.js] +var x = { x: 20 }.x; +//# sourceMappingURL=sourceMapValidationDestructuringObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js.map b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js.map new file mode 100644 index 00000000000..c428ab3f5fc --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringObjectBindingPattern1.js.map] +{"version":3,"file":"sourceMapValidationDestructuringObjectBindingPattern1.js","sourceRoot":"","sources":["sourceMapValidationDestructuringObjectBindingPattern1.ts"],"names":[],"mappings":"AACK,mBAAC,CAAc"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.sourcemap.txt new file mode 100644 index 00000000000..5dd6c7410dd --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.sourcemap.txt @@ -0,0 +1,24 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringObjectBindingPattern1.js +mapUrl: sourceMapValidationDestructuringObjectBindingPattern1.js.map +sourceRoot: +sources: sourceMapValidationDestructuringObjectBindingPattern1.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern1.js +sourceFile:sourceMapValidationDestructuringObjectBindingPattern1.ts +------------------------------------------------------------------- +>>>var x = { x: 20 }.x; +1 > +2 >^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >var { +2 >x +3 > } = { x: 20 }; +1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) +2 >Emitted(1, 20) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 21) Source(2, 21) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.symbols b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.symbols new file mode 100644 index 00000000000..b504acdb9b0 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern1.ts === + +var {x} = { x: 20 }; +>x : Symbol(x, Decl(sourceMapValidationDestructuringObjectBindingPattern1.ts, 1, 5)) +>x : Symbol(x, Decl(sourceMapValidationDestructuringObjectBindingPattern1.ts, 1, 11)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.types b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.types new file mode 100644 index 00000000000..0c051f80c45 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern1.ts === + +var {x} = { x: 20 }; +>x : number +>{ x: 20 } : { x: number; } +>x : number +>20 : number + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js new file mode 100644 index 00000000000..38cc7985925 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js @@ -0,0 +1,9 @@ +//// [sourceMapValidationDestructuringObjectBindingPattern2.ts] + +var {x} = { x: 20 }; +var { a, b } = { a: 30, b: 40 }; + +//// [sourceMapValidationDestructuringObjectBindingPattern2.js] +var x = { x: 20 }.x; +var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; +//# sourceMappingURL=sourceMapValidationDestructuringObjectBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js.map b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js.map new file mode 100644 index 00000000000..af59ee6fae0 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringObjectBindingPattern2.js.map] +{"version":3,"file":"sourceMapValidationDestructuringObjectBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringObjectBindingPattern2.ts"],"names":[],"mappings":"AACK,mBAAC,CAAc;AACpB,IAAA,qBAA+B,EAAzB,QAAC,EAAE,QAAC,CAAsB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.sourcemap.txt new file mode 100644 index 00000000000..38dc23ba462 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.sourcemap.txt @@ -0,0 +1,52 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringObjectBindingPattern2.js +mapUrl: sourceMapValidationDestructuringObjectBindingPattern2.js.map +sourceRoot: +sources: sourceMapValidationDestructuringObjectBindingPattern2.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern2.js +sourceFile:sourceMapValidationDestructuringObjectBindingPattern2.ts +------------------------------------------------------------------- +>>>var x = { x: 20 }.x; +1 > +2 >^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >var { +2 >x +3 > } = { x: 20 }; +1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) +2 >Emitted(1, 20) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 21) Source(2, 21) + SourceIndex(0) +--- +>>>var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; +1-> +2 >^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^ +6 > ^^ +7 > ^^^^^^^^ +8 > ^ +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +2 > +3 > var { a, b } = { a: 30, b: 40 } +4 > +5 > a +6 > , +7 > b +8 > } = { a: 30, b: 40 }; +1->Emitted(2, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(3, 1) + SourceIndex(0) +3 >Emitted(2, 26) Source(3, 32) + SourceIndex(0) +4 >Emitted(2, 28) Source(3, 7) + SourceIndex(0) +5 >Emitted(2, 36) Source(3, 8) + SourceIndex(0) +6 >Emitted(2, 38) Source(3, 10) + SourceIndex(0) +7 >Emitted(2, 46) Source(3, 11) + SourceIndex(0) +8 >Emitted(2, 47) Source(3, 33) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringObjectBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.symbols b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.symbols new file mode 100644 index 00000000000..dcc213f135c --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern2.ts === + +var {x} = { x: 20 }; +>x : Symbol(x, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 1, 5)) +>x : Symbol(x, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 1, 11)) + +var { a, b } = { a: 30, b: 40 }; +>a : Symbol(a, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 2, 5)) +>b : Symbol(b, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 2, 8)) +>a : Symbol(a, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 2, 16)) +>b : Symbol(b, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 2, 23)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.types new file mode 100644 index 00000000000..bbec608f686 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern2.ts === + +var {x} = { x: 20 }; +>x : number +>{ x: 20 } : { x: number; } +>x : number +>20 : number + +var { a, b } = { a: 30, b: 40 }; +>a : number +>b : number +>{ a: 30, b: 40 } : { a: number; b: number; } +>a : number +>30 : number +>b : number +>40 : number + From d81565398801e83e41e4392d8f8f325e099611b0 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 1 Feb 2016 09:45:27 -0800 Subject: [PATCH 004/102] Rename test cases so they are consistent with the rest --- ...tionDestructuringVariableStatementObjectBindingPattern1.ts | 3 +++ ...tionDestructuringVariableStatementObjectBindingPattern2.ts | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts create mode 100644 tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts diff --git a/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts new file mode 100644 index 00000000000..80adb1cf0c1 --- /dev/null +++ b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts @@ -0,0 +1,3 @@ +// @sourcemap: true + +var {x} = { x: 20 }; \ No newline at end of file diff --git a/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts new file mode 100644 index 00000000000..93465864cd6 --- /dev/null +++ b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts @@ -0,0 +1,4 @@ +// @sourcemap: true + +var {x} = { x: 20 }; +var { a, b } = { a: 30, b: 40 }; \ No newline at end of file From c7bbda8a3e23c35c76d748b74d2136671ea88ed2 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 1 Feb 2016 11:23:03 -0800 Subject: [PATCH 005/102] Remove old baselines --- ...ationDestructuringObjectBindingPattern1.js | 7 --- ...nDestructuringObjectBindingPattern1.js.map | 2 - ...cturingObjectBindingPattern1.sourcemap.txt | 24 --------- ...DestructuringObjectBindingPattern1.symbols | 6 --- ...onDestructuringObjectBindingPattern1.types | 8 --- ...ationDestructuringObjectBindingPattern2.js | 9 ---- ...nDestructuringObjectBindingPattern2.js.map | 2 - ...cturingObjectBindingPattern2.sourcemap.txt | 52 ------------------- ...DestructuringObjectBindingPattern2.symbols | 12 ----- ...onDestructuringObjectBindingPattern2.types | 17 ------ 10 files changed, 139 deletions(-) delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js.map delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.sourcemap.txt delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.symbols delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.types delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js.map delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.sourcemap.txt delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.symbols delete mode 100644 tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.types diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js deleted file mode 100644 index c4e56eefe1e..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js +++ /dev/null @@ -1,7 +0,0 @@ -//// [sourceMapValidationDestructuringObjectBindingPattern1.ts] - -var {x} = { x: 20 }; - -//// [sourceMapValidationDestructuringObjectBindingPattern1.js] -var x = { x: 20 }.x; -//# sourceMappingURL=sourceMapValidationDestructuringObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js.map b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js.map deleted file mode 100644 index c428ab3f5fc..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [sourceMapValidationDestructuringObjectBindingPattern1.js.map] -{"version":3,"file":"sourceMapValidationDestructuringObjectBindingPattern1.js","sourceRoot":"","sources":["sourceMapValidationDestructuringObjectBindingPattern1.ts"],"names":[],"mappings":"AACK,mBAAC,CAAc"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.sourcemap.txt deleted file mode 100644 index 5dd6c7410dd..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.sourcemap.txt +++ /dev/null @@ -1,24 +0,0 @@ -=================================================================== -JsFile: sourceMapValidationDestructuringObjectBindingPattern1.js -mapUrl: sourceMapValidationDestructuringObjectBindingPattern1.js.map -sourceRoot: -sources: sourceMapValidationDestructuringObjectBindingPattern1.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern1.js -sourceFile:sourceMapValidationDestructuringObjectBindingPattern1.ts -------------------------------------------------------------------- ->>>var x = { x: 20 }.x; -1 > -2 >^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - >var { -2 >x -3 > } = { x: 20 }; -1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) -2 >Emitted(1, 20) Source(2, 7) + SourceIndex(0) -3 >Emitted(1, 21) Source(2, 21) + SourceIndex(0) ---- ->>>//# sourceMappingURL=sourceMapValidationDestructuringObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.symbols b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.symbols deleted file mode 100644 index b504acdb9b0..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.symbols +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern1.ts === - -var {x} = { x: 20 }; ->x : Symbol(x, Decl(sourceMapValidationDestructuringObjectBindingPattern1.ts, 1, 5)) ->x : Symbol(x, Decl(sourceMapValidationDestructuringObjectBindingPattern1.ts, 1, 11)) - diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.types b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.types deleted file mode 100644 index 0c051f80c45..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern1.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern1.ts === - -var {x} = { x: 20 }; ->x : number ->{ x: 20 } : { x: number; } ->x : number ->20 : number - diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js deleted file mode 100644 index 38cc7985925..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [sourceMapValidationDestructuringObjectBindingPattern2.ts] - -var {x} = { x: 20 }; -var { a, b } = { a: 30, b: 40 }; - -//// [sourceMapValidationDestructuringObjectBindingPattern2.js] -var x = { x: 20 }.x; -var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; -//# sourceMappingURL=sourceMapValidationDestructuringObjectBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js.map b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js.map deleted file mode 100644 index af59ee6fae0..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.js.map +++ /dev/null @@ -1,2 +0,0 @@ -//// [sourceMapValidationDestructuringObjectBindingPattern2.js.map] -{"version":3,"file":"sourceMapValidationDestructuringObjectBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringObjectBindingPattern2.ts"],"names":[],"mappings":"AACK,mBAAC,CAAc;AACpB,IAAA,qBAA+B,EAAzB,QAAC,EAAE,QAAC,CAAsB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.sourcemap.txt deleted file mode 100644 index 38dc23ba462..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.sourcemap.txt +++ /dev/null @@ -1,52 +0,0 @@ -=================================================================== -JsFile: sourceMapValidationDestructuringObjectBindingPattern2.js -mapUrl: sourceMapValidationDestructuringObjectBindingPattern2.js.map -sourceRoot: -sources: sourceMapValidationDestructuringObjectBindingPattern2.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern2.js -sourceFile:sourceMapValidationDestructuringObjectBindingPattern2.ts -------------------------------------------------------------------- ->>>var x = { x: 20 }.x; -1 > -2 >^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - >var { -2 >x -3 > } = { x: 20 }; -1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) -2 >Emitted(1, 20) Source(2, 7) + SourceIndex(0) -3 >Emitted(1, 21) Source(2, 21) + SourceIndex(0) ---- ->>>var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; -1-> -2 >^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^ -4 > ^^ -5 > ^^^^^^^^ -6 > ^^ -7 > ^^^^^^^^ -8 > ^ -9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -2 > -3 > var { a, b } = { a: 30, b: 40 } -4 > -5 > a -6 > , -7 > b -8 > } = { a: 30, b: 40 }; -1->Emitted(2, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(3, 1) + SourceIndex(0) -3 >Emitted(2, 26) Source(3, 32) + SourceIndex(0) -4 >Emitted(2, 28) Source(3, 7) + SourceIndex(0) -5 >Emitted(2, 36) Source(3, 8) + SourceIndex(0) -6 >Emitted(2, 38) Source(3, 10) + SourceIndex(0) -7 >Emitted(2, 46) Source(3, 11) + SourceIndex(0) -8 >Emitted(2, 47) Source(3, 33) + SourceIndex(0) ---- ->>>//# sourceMappingURL=sourceMapValidationDestructuringObjectBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.symbols b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.symbols deleted file mode 100644 index dcc213f135c..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.symbols +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern2.ts === - -var {x} = { x: 20 }; ->x : Symbol(x, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 1, 5)) ->x : Symbol(x, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 1, 11)) - -var { a, b } = { a: 30, b: 40 }; ->a : Symbol(a, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 2, 5)) ->b : Symbol(b, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 2, 8)) ->a : Symbol(a, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 2, 16)) ->b : Symbol(b, Decl(sourceMapValidationDestructuringObjectBindingPattern2.ts, 2, 23)) - diff --git a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.types deleted file mode 100644 index bbec608f686..00000000000 --- a/tests/baselines/reference/sourceMapValidationDestructuringObjectBindingPattern2.types +++ /dev/null @@ -1,17 +0,0 @@ -=== tests/cases/compiler/sourceMapValidationDestructuringObjectBindingPattern2.ts === - -var {x} = { x: 20 }; ->x : number ->{ x: 20 } : { x: number; } ->x : number ->20 : number - -var { a, b } = { a: 30, b: 40 }; ->a : number ->b : number ->{ a: 30, b: 40 } : { a: number; b: number; } ->a : number ->30 : number ->b : number ->40 : number - From 0db90b786986c99770b35a280547f967153a7daa Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 1 Feb 2016 11:23:17 -0800 Subject: [PATCH 006/102] Add more tests and baselines --- ...ngVariableStatementArrayBindingPattern4.js | 7 +++ ...riableStatementArrayBindingPattern4.js.map | 2 + ...tatementArrayBindingPattern4.sourcemap.txt | 24 +++++++++ ...iableStatementArrayBindingPattern4.symbols | 5 ++ ...ariableStatementArrayBindingPattern4.types | 8 +++ ...ngVariableStatementArrayBindingPattern5.js | 9 ++++ ...riableStatementArrayBindingPattern5.js.map | 2 + ...tatementArrayBindingPattern5.sourcemap.txt | 52 +++++++++++++++++++ ...iableStatementArrayBindingPattern5.symbols | 9 ++++ ...ariableStatementArrayBindingPattern5.types | 15 ++++++ ...ngVariableStatementArrayBindingPattern6.js | 7 +++ ...riableStatementArrayBindingPattern6.js.map | 2 + ...tatementArrayBindingPattern6.sourcemap.txt | 30 +++++++++++ ...iableStatementArrayBindingPattern6.symbols | 5 ++ ...ariableStatementArrayBindingPattern6.types | 9 ++++ ...ngVariableStatementArrayBindingPattern7.js | 7 +++ ...riableStatementArrayBindingPattern7.js.map | 2 + ...tatementArrayBindingPattern7.sourcemap.txt | 45 ++++++++++++++++ ...iableStatementArrayBindingPattern7.symbols | 6 +++ ...ariableStatementArrayBindingPattern7.types | 10 ++++ ...gVariableStatementObjectBindingPattern1.js | 7 +++ ...iableStatementObjectBindingPattern1.js.map | 2 + ...atementObjectBindingPattern1.sourcemap.txt | 24 +++++++++ ...ableStatementObjectBindingPattern1.symbols | 6 +++ ...riableStatementObjectBindingPattern1.types | 8 +++ ...gVariableStatementObjectBindingPattern2.js | 9 ++++ ...iableStatementObjectBindingPattern2.js.map | 2 + ...atementObjectBindingPattern2.sourcemap.txt | 52 +++++++++++++++++++ ...ableStatementObjectBindingPattern2.symbols | 12 +++++ ...riableStatementObjectBindingPattern2.types | 17 ++++++ ...gVariableStatementObjectBindingPattern3.js | 7 +++ ...iableStatementObjectBindingPattern3.js.map | 2 + ...atementObjectBindingPattern3.sourcemap.txt | 30 +++++++++++ ...ableStatementObjectBindingPattern3.symbols | 6 +++ ...riableStatementObjectBindingPattern3.types | 9 ++++ ...gVariableStatementObjectBindingPattern4.js | 8 +++ ...iableStatementObjectBindingPattern4.js.map | 2 + ...atementObjectBindingPattern4.sourcemap.txt | 47 +++++++++++++++++ ...ableStatementObjectBindingPattern4.symbols | 10 ++++ ...riableStatementObjectBindingPattern4.types | 14 +++++ ...ngVariableStatementArrayBindingPattern4.ts | 3 ++ ...ngVariableStatementArrayBindingPattern5.ts | 4 ++ ...ngVariableStatementArrayBindingPattern6.ts | 3 ++ ...ngVariableStatementArrayBindingPattern7.ts | 3 ++ ...gVariableStatementObjectBindingPattern3.ts | 3 ++ ...gVariableStatementObjectBindingPattern4.ts | 4 ++ 46 files changed, 550 insertions(+) create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.types create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.types create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.types create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.types create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.types create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.types create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.types create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.sourcemap.txt create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.symbols create mode 100644 tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.types create mode 100644 tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts create mode 100644 tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts create mode 100644 tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts create mode 100644 tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts create mode 100644 tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts create mode 100644 tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js new file mode 100644 index 00000000000..d4c419278c7 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js @@ -0,0 +1,7 @@ +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts] + +var [x] = [1, 2]; + +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js] +var x = [1, 2][0]; +//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js.map new file mode 100644 index 00000000000..96fd86faa4e --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js.map] +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts"],"names":[],"mappings":"AACK,iBAAC,CAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.sourcemap.txt new file mode 100644 index 00000000000..a52c7701db2 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.sourcemap.txt @@ -0,0 +1,24 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js +mapUrl: sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js.map +sourceRoot: +sources: sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js +sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts +------------------------------------------------------------------- +>>>var x = [1, 2][0]; +1 > +2 >^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >var [ +2 >x +3 > ] = [1, 2]; +1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) +2 >Emitted(1, 18) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 19) Source(2, 18) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.symbols b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.symbols new file mode 100644 index 00000000000..4695a8cd598 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts === + +var [x] = [1, 2]; +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts, 1, 5)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.types new file mode 100644 index 00000000000..461939a11aa --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts === + +var [x] = [1, 2]; +>x : number +>[1, 2] : [number, number] +>1 : number +>2 : number + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js new file mode 100644 index 00000000000..10df853c220 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js @@ -0,0 +1,9 @@ +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts] + +var [x] = [1, 2]; +var [y, z] = [1, 2]; + +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js] +var x = [1, 2][0]; +var _a = [1, 2], y = _a[0], z = _a[1]; +//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map new file mode 100644 index 00000000000..337a73240b9 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map] +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts"],"names":[],"mappings":"AACK,iBAAC,CAAW;AACjB,IAAA,WAAmB,EAAd,SAAC,EAAE,SAAC,CAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.sourcemap.txt new file mode 100644 index 00000000000..338b6424185 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.sourcemap.txt @@ -0,0 +1,52 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js +mapUrl: sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map +sourceRoot: +sources: sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js +sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts +------------------------------------------------------------------- +>>>var x = [1, 2][0]; +1 > +2 >^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^^-> +1 > + >var [ +2 >x +3 > ] = [1, 2]; +1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) +2 >Emitted(1, 18) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 19) Source(2, 18) + SourceIndex(0) +--- +>>>var _a = [1, 2], y = _a[0], z = _a[1]; +1-> +2 >^^^^ +3 > ^^^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^^ +6 > ^^ +7 > ^^^^^^^^^ +8 > ^ +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +2 > +3 > var [y, z] = [1, 2] +4 > +5 > y +6 > , +7 > z +8 > ] = [1, 2]; +1->Emitted(2, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(3, 1) + SourceIndex(0) +3 >Emitted(2, 16) Source(3, 20) + SourceIndex(0) +4 >Emitted(2, 18) Source(3, 6) + SourceIndex(0) +5 >Emitted(2, 27) Source(3, 7) + SourceIndex(0) +6 >Emitted(2, 29) Source(3, 9) + SourceIndex(0) +7 >Emitted(2, 38) Source(3, 10) + SourceIndex(0) +8 >Emitted(2, 39) Source(3, 21) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.symbols b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.symbols new file mode 100644 index 00000000000..59543290772 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts === + +var [x] = [1, 2]; +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts, 1, 5)) + +var [y, z] = [1, 2]; +>y : Symbol(y, Decl(sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts, 2, 5)) +>z : Symbol(z, Decl(sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts, 2, 7)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.types new file mode 100644 index 00000000000..1ef747517e4 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts === + +var [x] = [1, 2]; +>x : number +>[1, 2] : [number, number] +>1 : number +>2 : number + +var [y, z] = [1, 2]; +>y : number +>z : number +>[1, 2] : [number, number] +>1 : number +>2 : number + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js new file mode 100644 index 00000000000..d4baadb6562 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js @@ -0,0 +1,7 @@ +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts] + +var [x = 20] = [1, 2]; + +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js] +var _a = [1, 2][0], x = _a === void 0 ? 20 : _a; +//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js.map new file mode 100644 index 00000000000..9594cc22809 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js.map] +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts"],"names":[],"mappings":"AACK,kBAAM,EAAN,2BAAM,CAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.sourcemap.txt new file mode 100644 index 00000000000..90ebe4dc9ac --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.sourcemap.txt @@ -0,0 +1,30 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js +mapUrl: sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js.map +sourceRoot: +sources: sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js +sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts +------------------------------------------------------------------- +>>>var _a = [1, 2][0], x = _a === void 0 ? 20 : _a; +1 > +2 >^^^^^^^^^^^^^^^^^^ +3 > ^^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +5 > ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >var [ +2 >x = 20 +3 > +4 > x = 20 +5 > ] = [1, 2]; +1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) +2 >Emitted(1, 19) Source(2, 12) + SourceIndex(0) +3 >Emitted(1, 21) Source(2, 6) + SourceIndex(0) +4 >Emitted(1, 48) Source(2, 12) + SourceIndex(0) +5 >Emitted(1, 49) Source(2, 23) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.symbols b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.symbols new file mode 100644 index 00000000000..6c368f4996e --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts === + +var [x = 20] = [1, 2]; +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts, 1, 5)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.types new file mode 100644 index 00000000000..1b94874ae7c --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts === + +var [x = 20] = [1, 2]; +>x : number +>20 : number +>[1, 2] : [number, number] +>1 : number +>2 : number + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js new file mode 100644 index 00000000000..73d2e85e9da --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js @@ -0,0 +1,7 @@ +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts] + +var [x = 20, j] = [1, 2]; + +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js] +var _a = [1, 2], _b = _a[0], x = _b === void 0 ? 20 : _b, j = _a[1]; +//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map new file mode 100644 index 00000000000..0def6b1a730 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map] +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts"],"names":[],"mappings":"AACA,IAAA,WAAwB,EAAnB,UAAM,EAAN,2BAAM,EAAE,SAAC,CAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.sourcemap.txt new file mode 100644 index 00000000000..f2a95375f2a --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.sourcemap.txt @@ -0,0 +1,45 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js +mapUrl: sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map +sourceRoot: +sources: sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js +sourceFile:sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts +------------------------------------------------------------------- +>>>var _a = [1, 2], _b = _a[0], x = _b === void 0 ? 20 : _b, j = _a[1]; +1 > +2 >^^^^ +3 > ^^^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^^^ +6 > ^^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +8 > ^^ +9 > ^^^^^^^^^ +10> ^ +11> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > +3 > var [x = 20, j] = [1, 2] +4 > +5 > x = 20 +6 > +7 > x = 20 +8 > , +9 > j +10> ] = [1, 2]; +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(2, 1) + SourceIndex(0) +3 >Emitted(1, 16) Source(2, 25) + SourceIndex(0) +4 >Emitted(1, 18) Source(2, 6) + SourceIndex(0) +5 >Emitted(1, 28) Source(2, 12) + SourceIndex(0) +6 >Emitted(1, 30) Source(2, 6) + SourceIndex(0) +7 >Emitted(1, 57) Source(2, 12) + SourceIndex(0) +8 >Emitted(1, 59) Source(2, 14) + SourceIndex(0) +9 >Emitted(1, 68) Source(2, 15) + SourceIndex(0) +10>Emitted(1, 69) Source(2, 26) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.symbols b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.symbols new file mode 100644 index 00000000000..4f57dffff26 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts === + +var [x = 20, j] = [1, 2]; +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts, 1, 5)) +>j : Symbol(j, Decl(sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts, 1, 12)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.types new file mode 100644 index 00000000000..9b369e410a4 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts === + +var [x = 20, j] = [1, 2]; +>x : number +>20 : number +>j : number +>[1, 2] : [number, number] +>1 : number +>2 : number + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js new file mode 100644 index 00000000000..8259981857c --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js @@ -0,0 +1,7 @@ +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts] + +var {x} = { x: 20 }; + +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js] +var x = { x: 20 }.x; +//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map new file mode 100644 index 00000000000..5ecd5985927 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map] +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts"],"names":[],"mappings":"AACK,mBAAC,CAAc"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt new file mode 100644 index 00000000000..8e5860c7a77 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt @@ -0,0 +1,24 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js +mapUrl: sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map +sourceRoot: +sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js +sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts +------------------------------------------------------------------- +>>>var x = { x: 20 }.x; +1 > +2 >^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >var { +2 >x +3 > } = { x: 20 }; +1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) +2 >Emitted(1, 20) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 21) Source(2, 21) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.symbols b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.symbols new file mode 100644 index 00000000000..950fca4eb00 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts === + +var {x} = { x: 20 }; +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts, 1, 5)) +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts, 1, 11)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.types new file mode 100644 index 00000000000..c975a9eaae5 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts === + +var {x} = { x: 20 }; +>x : number +>{ x: 20 } : { x: number; } +>x : number +>20 : number + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js new file mode 100644 index 00000000000..d4d52e5e8d9 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js @@ -0,0 +1,9 @@ +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts] + +var {x} = { x: 20 }; +var { a, b } = { a: 30, b: 40 }; + +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js] +var x = { x: 20 }.x; +var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; +//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map new file mode 100644 index 00000000000..6d3a8b40d22 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map] +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts"],"names":[],"mappings":"AACK,mBAAC,CAAc;AACpB,IAAA,qBAA+B,EAAzB,QAAC,EAAE,QAAC,CAAsB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt new file mode 100644 index 00000000000..e9454cb2bfa --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt @@ -0,0 +1,52 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js +mapUrl: sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map +sourceRoot: +sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js +sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts +------------------------------------------------------------------- +>>>var x = { x: 20 }.x; +1 > +2 >^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >var { +2 >x +3 > } = { x: 20 }; +1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) +2 >Emitted(1, 20) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 21) Source(2, 21) + SourceIndex(0) +--- +>>>var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; +1-> +2 >^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^ +6 > ^^ +7 > ^^^^^^^^ +8 > ^ +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +2 > +3 > var { a, b } = { a: 30, b: 40 } +4 > +5 > a +6 > , +7 > b +8 > } = { a: 30, b: 40 }; +1->Emitted(2, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(3, 1) + SourceIndex(0) +3 >Emitted(2, 26) Source(3, 32) + SourceIndex(0) +4 >Emitted(2, 28) Source(3, 7) + SourceIndex(0) +5 >Emitted(2, 36) Source(3, 8) + SourceIndex(0) +6 >Emitted(2, 38) Source(3, 10) + SourceIndex(0) +7 >Emitted(2, 46) Source(3, 11) + SourceIndex(0) +8 >Emitted(2, 47) Source(3, 33) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.symbols b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.symbols new file mode 100644 index 00000000000..4fa80ecf05e --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts === + +var {x} = { x: 20 }; +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts, 1, 5)) +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts, 1, 11)) + +var { a, b } = { a: 30, b: 40 }; +>a : Symbol(a, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts, 2, 5)) +>b : Symbol(b, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts, 2, 8)) +>a : Symbol(a, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts, 2, 16)) +>b : Symbol(b, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts, 2, 23)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.types new file mode 100644 index 00000000000..a694d4ecd29 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts === + +var {x} = { x: 20 }; +>x : number +>{ x: 20 } : { x: number; } +>x : number +>20 : number + +var { a, b } = { a: 30, b: 40 }; +>a : number +>b : number +>{ a: 30, b: 40 } : { a: number; b: number; } +>a : number +>30 : number +>b : number +>40 : number + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js new file mode 100644 index 00000000000..f146e4bb8a7 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js @@ -0,0 +1,7 @@ +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts] + +var {x = 500} = { x: 20 }; + +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js] +var _a = { x: 20 }.x, x = _a === void 0 ? 500 : _a; +//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map new file mode 100644 index 00000000000..975a48aa0ee --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map] +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts"],"names":[],"mappings":"AACK,oBAAO,EAAP,4BAAO,CAAc"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt new file mode 100644 index 00000000000..2fa0c81199b --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt @@ -0,0 +1,30 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js +mapUrl: sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map +sourceRoot: +sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js +sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts +------------------------------------------------------------------- +>>>var _a = { x: 20 }.x, x = _a === void 0 ? 500 : _a; +1 > +2 >^^^^^^^^^^^^^^^^^^^^ +3 > ^^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +5 > ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >var { +2 >x = 500 +3 > +4 > x = 500 +5 > } = { x: 20 }; +1 >Emitted(1, 1) Source(2, 6) + SourceIndex(0) +2 >Emitted(1, 21) Source(2, 13) + SourceIndex(0) +3 >Emitted(1, 23) Source(2, 6) + SourceIndex(0) +4 >Emitted(1, 51) Source(2, 13) + SourceIndex(0) +5 >Emitted(1, 52) Source(2, 27) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.symbols b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.symbols new file mode 100644 index 00000000000..a668ab8e733 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts === + +var {x = 500} = { x: 20 }; +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts, 1, 5)) +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts, 1, 17)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.types new file mode 100644 index 00000000000..bec1b195c98 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts === + +var {x = 500} = { x: 20 }; +>x : number +>500 : number +>{ x: 20 } : { x?: number; } +>x : number +>20 : number + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js new file mode 100644 index 00000000000..d785d2dd1fd --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js @@ -0,0 +1,8 @@ +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts] + +var {x = 500, + y} = { x: 20, y: "hi" }; + +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js] +var _a = { x: 20, y: "hi" }, _b = _a.x, x = _b === void 0 ? 500 : _b, y = _a.y; +//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map new file mode 100644 index 00000000000..e0b108863b0 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map @@ -0,0 +1,2 @@ +//// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map] +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts"],"names":[],"mappings":"AACA,IAAA,uBAC4B,EADvB,SAAO,EAAP,4BAAO,EACP,QAAC,CAAuB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.sourcemap.txt new file mode 100644 index 00000000000..6ae979f8ade --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.sourcemap.txt @@ -0,0 +1,47 @@ +=================================================================== +JsFile: sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js +mapUrl: sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map +sourceRoot: +sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js +sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts +------------------------------------------------------------------- +>>>var _a = { x: 20, y: "hi" }, _b = _a.x, x = _b === void 0 ? 500 : _b, y = _a.y; +1 > +2 >^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^^ +6 > ^^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +8 > ^^ +9 > ^^^^^^^^ +10> ^ +11> ^^^^^^^^^^^^^^^^^^-> +1 > + > +2 > +3 > var {x = 500, + > y} = { x: 20, y: "hi" } +4 > +5 > x = 500 +6 > +7 > x = 500 +8 > , + > +9 > y +10> } = { x: 20, y: "hi" }; +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(2, 1) + SourceIndex(0) +3 >Emitted(1, 28) Source(3, 29) + SourceIndex(0) +4 >Emitted(1, 30) Source(2, 6) + SourceIndex(0) +5 >Emitted(1, 39) Source(2, 13) + SourceIndex(0) +6 >Emitted(1, 41) Source(2, 6) + SourceIndex(0) +7 >Emitted(1, 69) Source(2, 13) + SourceIndex(0) +8 >Emitted(1, 71) Source(3, 6) + SourceIndex(0) +9 >Emitted(1, 79) Source(3, 7) + SourceIndex(0) +10>Emitted(1, 80) Source(3, 30) + SourceIndex(0) +--- +>>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.symbols b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.symbols new file mode 100644 index 00000000000..8404c342c0b --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts === + +var {x = 500, +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts, 1, 5)) + + y} = { x: 20, y: "hi" }; +>y : Symbol(y, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts, 1, 13)) +>x : Symbol(x, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts, 2, 11)) +>y : Symbol(y, Decl(sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts, 2, 18)) + diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.types new file mode 100644 index 00000000000..1d00ac2d56b --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts === + +var {x = 500, +>x : number +>500 : number + + y} = { x: 20, y: "hi" }; +>y : string +>{ x: 20, y: "hi" } : { x?: number; y: string; } +>x : number +>20 : number +>y : string +>"hi" : string + diff --git a/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts new file mode 100644 index 00000000000..da41b8ca49f --- /dev/null +++ b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts @@ -0,0 +1,3 @@ +// @sourcemap: true + +var [x] = [1, 2]; \ No newline at end of file diff --git a/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts new file mode 100644 index 00000000000..8e9d05fadd5 --- /dev/null +++ b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts @@ -0,0 +1,4 @@ +// @sourcemap: true + +var [x] = [1, 2]; +var [y, z] = [1, 2]; \ No newline at end of file diff --git a/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts new file mode 100644 index 00000000000..6c3ea7bedd7 --- /dev/null +++ b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts @@ -0,0 +1,3 @@ +// @sourcemap: true + +var [x = 20] = [1, 2]; \ No newline at end of file diff --git a/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts new file mode 100644 index 00000000000..d9d91eb578b --- /dev/null +++ b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.ts @@ -0,0 +1,3 @@ +// @sourcemap: true + +var [x = 20, j] = [1, 2]; \ No newline at end of file diff --git a/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts new file mode 100644 index 00000000000..5af6b55272f --- /dev/null +++ b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts @@ -0,0 +1,3 @@ +// @sourcemap: true + +var {x = 500} = { x: 20 }; \ No newline at end of file diff --git a/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts new file mode 100644 index 00000000000..e0afcb60c27 --- /dev/null +++ b/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.ts @@ -0,0 +1,4 @@ +// @sourcemap: true + +var {x = 500, + y} = { x: 20, y: "hi" }; \ No newline at end of file From 2c25bea0aaec64e17e12b0c11f456a821abb3064 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 2 Feb 2016 13:10:30 -0800 Subject: [PATCH 007/102] Always show file tokens in JS completion lists Fixes #6654 --- src/services/services.ts | 2 +- .../fourslash/getJavaScriptGlobalCompletions1.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts diff --git a/src/services/services.ts b/src/services/services.ts index 85b2bfb58e8..1204b63c9fb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3834,7 +3834,7 @@ namespace ts { const entries: CompletionEntry[] = []; - if (isRightOfDot && isSourceFileJavaScript(sourceFile)) { + if (isSourceFileJavaScript(sourceFile)) { const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } diff --git a/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts b/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts new file mode 100644 index 00000000000..240df24bf52 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts @@ -0,0 +1,15 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// function f() { +//// // helloWorld leaks from here into the global space? +//// if (helloWorld) { +//// return 3; +//// } +//// return 5; +//// } +//// +//// hello/**/ + +verify.completionListContains('helloWorld'); From 6e06bb39a13281c6080e973e1a015aea66e8b9ce Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 2 Feb 2016 13:32:21 -0800 Subject: [PATCH 008/102] Allow parsing TS-style generics in JSDoc Fixes #6814 --- src/compiler/parser.ts | 20 +++++++++++++------- tests/cases/fourslash/jsDocGenerics1.ts | 10 ++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 tests/cases/fourslash/jsDocGenerics1.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b6ba02b987c..99ceafb15cb 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5734,16 +5734,22 @@ namespace ts { const result = createNode(SyntaxKind.JSDocTypeReference); result.name = parseSimplePropertyName(); - while (parseOptional(SyntaxKind.DotToken)) { - if (token === SyntaxKind.LessThanToken) { - result.typeArguments = parseTypeArguments(); - break; - } - else { - result.name = parseQualifiedName(result.name); + if (token === SyntaxKind.LessThanToken) { + result.typeArguments = parseTypeArguments(); + } + else { + while (parseOptional(SyntaxKind.DotToken)) { + if (token === SyntaxKind.LessThanToken) { + result.typeArguments = parseTypeArguments(); + break; + } + else { + result.name = parseQualifiedName(result.name); + } } } + return finishNode(result); } diff --git a/tests/cases/fourslash/jsDocGenerics1.ts b/tests/cases/fourslash/jsDocGenerics1.ts new file mode 100644 index 00000000000..3b5742af8b1 --- /dev/null +++ b/tests/cases/fourslash/jsDocGenerics1.ts @@ -0,0 +1,10 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// /** @type {Array} */ +//// var v; +//// v[0]./**/ + +goTo.marker(); +verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); From 018429bd6ec9629b338c6a591b723d1f33f1ca4f Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 2 Feb 2016 13:39:02 -0800 Subject: [PATCH 009/102] :heart: linter --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 1204b63c9fb..6761c487c6c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3823,7 +3823,7 @@ namespace ts { return undefined; } - const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData; + const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion From c89f2b75ad7e7557a6df33918b62ede8b149fce4 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 2 Feb 2016 14:14:37 -0800 Subject: [PATCH 010/102] Properly parse function/constructor types with destructuring parameters --- src/compiler/parser.ts | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4ec83277e3e..77f50a9bd87 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2450,10 +2450,27 @@ namespace ts { if (token === SyntaxKind.LessThanToken) { return true; } - return token === SyntaxKind.OpenParenToken && lookAhead(isUnambiguouslyStartOfFunctionType); } + function skipParameterStart(): boolean { + if (isModifierKind(token)) { + // Skip modifiers + parseModifiers(); + } + if (isIdentifier()) { + nextToken(); + return true; + } + if (token === SyntaxKind.OpenBracketToken || token === SyntaxKind.OpenBraceToken) { + // Return true if we can parse an array or object binding pattern with no errors + const count = parseDiagnostics.length; + parseIdentifierOrPattern(); + return count === parseDiagnostics.length; + } + return false; + } + function isUnambiguouslyStartOfFunctionType() { nextToken(); if (token === SyntaxKind.CloseParenToken || token === SyntaxKind.DotDotDotToken) { @@ -2461,16 +2478,15 @@ namespace ts { // ( ... return true; } - if (isIdentifier() || isModifierKind(token)) { - nextToken(); + if (skipParameterStart()) { + // We successfully skipped modifiers (if any) and an identifier or binding pattern, + // now see if we have something that indicates a parameter declaration if (token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken || - token === SyntaxKind.QuestionToken || token === SyntaxKind.EqualsToken || - isIdentifier() || isModifierKind(token)) { - // ( id : - // ( id , - // ( id ? - // ( id = - // ( modifier id + token === SyntaxKind.QuestionToken || token === SyntaxKind.EqualsToken) { + // ( xxx : + // ( xxx , + // ( xxx ? + // ( xxx = return true; } if (token === SyntaxKind.CloseParenToken) { From 5643f911c7a63be09cb574840d444fea1e3f9a4f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 2 Feb 2016 14:14:55 -0800 Subject: [PATCH 011/102] Adding test --- .../destructuringInFunctionType.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/cases/conformance/es6/destructuring/destructuringInFunctionType.ts diff --git a/tests/cases/conformance/es6/destructuring/destructuringInFunctionType.ts b/tests/cases/conformance/es6/destructuring/destructuringInFunctionType.ts new file mode 100644 index 00000000000..51333b1ca53 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringInFunctionType.ts @@ -0,0 +1,22 @@ +// @declaration: true + +interface a { a } +interface b { b } +interface c { c } + +type T1 = ([a, b, c]); +type F1 = ([a, b, c]) => void; + +type T2 = ({ a }); +type F2 = ({ a }) => void; + +type T3 = ([{ a: b }, { b: a }]); +type F3 = ([{ a: b }, { b: a }]) => void; + +type T4 = ([{ a: [b, c] }]); +type F4 = ([{ a: [b, c] }]) => void; + +type C1 = new ([{ a: [b, c] }]) => void; + +var v1 = ([a, b, c]) => "hello"; +var v2: ([a, b, c]) => string; From 979186fad9a6e28a4f1fb8446621a0e88343e9fa Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 2 Feb 2016 14:15:26 -0800 Subject: [PATCH 012/102] Accepting new baselines --- .../reference/destructuringInFunctionType.js | 61 ++++++++++++++ .../destructuringInFunctionType.symbols | 78 ++++++++++++++++++ .../destructuringInFunctionType.types | 80 +++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 tests/baselines/reference/destructuringInFunctionType.js create mode 100644 tests/baselines/reference/destructuringInFunctionType.symbols create mode 100644 tests/baselines/reference/destructuringInFunctionType.types diff --git a/tests/baselines/reference/destructuringInFunctionType.js b/tests/baselines/reference/destructuringInFunctionType.js new file mode 100644 index 00000000000..ac187f5b43d --- /dev/null +++ b/tests/baselines/reference/destructuringInFunctionType.js @@ -0,0 +1,61 @@ +//// [destructuringInFunctionType.ts] + +interface a { a } +interface b { b } +interface c { c } + +type T1 = ([a, b, c]); +type F1 = ([a, b, c]) => void; + +type T2 = ({ a }); +type F2 = ({ a }) => void; + +type T3 = ([{ a: b }, { b: a }]); +type F3 = ([{ a: b }, { b: a }]) => void; + +type T4 = ([{ a: [b, c] }]); +type F4 = ([{ a: [b, c] }]) => void; + +type C1 = new ([{ a: [b, c] }]) => void; + +var v1 = ([a, b, c]) => "hello"; +var v2: ([a, b, c]) => string; + + +//// [destructuringInFunctionType.js] +var v1 = function (_a) { + var a = _a[0], b = _a[1], c = _a[2]; + return "hello"; +}; +var v2; + + +//// [destructuringInFunctionType.d.ts] +interface a { + a: any; +} +interface b { + b: any; +} +interface c { + c: any; +} +declare type T1 = ([a, b, c]); +declare type F1 = ([a, b, c]) => void; +declare type T2 = ({ + a; +}); +declare type F2 = ({a}) => void; +declare type T3 = ([{ + a: b; +}, { + b: a; +}]); +declare type F3 = ([{a: b}, {b: a}]) => void; +declare type T4 = ([{ + a: [b, c]; +}]); +declare type F4 = ([{a: [b, c]}]) => void; +declare type C1 = new ([{a: [b, c]}]) => void; +declare var v1: ([a, b, c]: [any, any, any]) => string; +declare var v2: ([a, b, c]) => string; diff --git a/tests/baselines/reference/destructuringInFunctionType.symbols b/tests/baselines/reference/destructuringInFunctionType.symbols new file mode 100644 index 00000000000..8b573905b76 --- /dev/null +++ b/tests/baselines/reference/destructuringInFunctionType.symbols @@ -0,0 +1,78 @@ +=== tests/cases/conformance/es6/destructuring/destructuringInFunctionType.ts === + +interface a { a } +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 0, 0)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 1, 13)) + +interface b { b } +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 1, 17)) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 2, 13)) + +interface c { c } +>c : Symbol(c, Decl(destructuringInFunctionType.ts, 2, 17)) +>c : Symbol(c, Decl(destructuringInFunctionType.ts, 3, 13)) + +type T1 = ([a, b, c]); +>T1 : Symbol(T1, Decl(destructuringInFunctionType.ts, 3, 17)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 0, 0)) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 1, 17)) +>c : Symbol(c, Decl(destructuringInFunctionType.ts, 2, 17)) + +type F1 = ([a, b, c]) => void; +>F1 : Symbol(F1, Decl(destructuringInFunctionType.ts, 5, 22)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 6, 12)) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 6, 14)) +>c : Symbol(c, Decl(destructuringInFunctionType.ts, 6, 17)) + +type T2 = ({ a }); +>T2 : Symbol(T2, Decl(destructuringInFunctionType.ts, 6, 30)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 8, 12)) + +type F2 = ({ a }) => void; +>F2 : Symbol(F2, Decl(destructuringInFunctionType.ts, 8, 18)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 9, 12)) + +type T3 = ([{ a: b }, { b: a }]); +>T3 : Symbol(T3, Decl(destructuringInFunctionType.ts, 9, 26)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 11, 13)) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 1, 17)) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 11, 23)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 0, 0)) + +type F3 = ([{ a: b }, { b: a }]) => void; +>F3 : Symbol(F3, Decl(destructuringInFunctionType.ts, 11, 33)) +>a : Symbol(a) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 12, 13)) +>b : Symbol(b) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 12, 23)) + +type T4 = ([{ a: [b, c] }]); +>T4 : Symbol(T4, Decl(destructuringInFunctionType.ts, 12, 41)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 14, 13)) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 1, 17)) +>c : Symbol(c, Decl(destructuringInFunctionType.ts, 2, 17)) + +type F4 = ([{ a: [b, c] }]) => void; +>F4 : Symbol(F4, Decl(destructuringInFunctionType.ts, 14, 28)) +>a : Symbol(a) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 15, 18)) +>c : Symbol(c, Decl(destructuringInFunctionType.ts, 15, 20)) + +type C1 = new ([{ a: [b, c] }]) => void; +>C1 : Symbol(C1, Decl(destructuringInFunctionType.ts, 15, 36)) +>a : Symbol(a) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 17, 22)) +>c : Symbol(c, Decl(destructuringInFunctionType.ts, 17, 24)) + +var v1 = ([a, b, c]) => "hello"; +>v1 : Symbol(v1, Decl(destructuringInFunctionType.ts, 19, 3)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 19, 11)) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 19, 13)) +>c : Symbol(c, Decl(destructuringInFunctionType.ts, 19, 16)) + +var v2: ([a, b, c]) => string; +>v2 : Symbol(v2, Decl(destructuringInFunctionType.ts, 20, 3)) +>a : Symbol(a, Decl(destructuringInFunctionType.ts, 20, 10)) +>b : Symbol(b, Decl(destructuringInFunctionType.ts, 20, 12)) +>c : Symbol(c, Decl(destructuringInFunctionType.ts, 20, 15)) + diff --git a/tests/baselines/reference/destructuringInFunctionType.types b/tests/baselines/reference/destructuringInFunctionType.types new file mode 100644 index 00000000000..8786bbd0bb9 --- /dev/null +++ b/tests/baselines/reference/destructuringInFunctionType.types @@ -0,0 +1,80 @@ +=== tests/cases/conformance/es6/destructuring/destructuringInFunctionType.ts === + +interface a { a } +>a : a +>a : any + +interface b { b } +>b : b +>b : any + +interface c { c } +>c : c +>c : any + +type T1 = ([a, b, c]); +>T1 : [a, b, c] +>a : a +>b : b +>c : c + +type F1 = ([a, b, c]) => void; +>F1 : ([a, b, c]: [any, any, any]) => void +>a : any +>b : any +>c : any + +type T2 = ({ a }); +>T2 : { a: any; } +>a : any + +type F2 = ({ a }) => void; +>F2 : ({ a }: { a: any; }) => void +>a : any + +type T3 = ([{ a: b }, { b: a }]); +>T3 : [{ a: b; }, { b: a; }] +>a : b +>b : b +>b : a +>a : a + +type F3 = ([{ a: b }, { b: a }]) => void; +>F3 : ([{ a: b }, { b: a }]: [{ a: any; }, { b: any; }]) => void +>a : any +>b : any +>b : any +>a : any + +type T4 = ([{ a: [b, c] }]); +>T4 : [{ a: [b, c]; }] +>a : [b, c] +>b : b +>c : c + +type F4 = ([{ a: [b, c] }]) => void; +>F4 : ([{ a: [b, c] }]: [{ a: [any, any]; }]) => void +>a : any +>b : any +>c : any + +type C1 = new ([{ a: [b, c] }]) => void; +>C1 : new ([{ a: [b, c] }]: [{ a: [any, any]; }]) => void +>a : any +>b : any +>c : any + +var v1 = ([a, b, c]) => "hello"; +>v1 : ([a, b, c]: [any, any, any]) => string +>([a, b, c]) => "hello" : ([a, b, c]: [any, any, any]) => string +>a : any +>b : any +>c : any +>"hello" : string + +var v2: ([a, b, c]) => string; +>v2 : ([a, b, c]: [any, any, any]) => string +>a : any +>b : any +>c : any + From 202452b521c54237a157d06159896e20cc8c57be Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 2 Feb 2016 15:53:20 -0800 Subject: [PATCH 013/102] emit import declarations without import clause in .d.ts files --- src/compiler/declarationEmitter.ts | 4 ---- tests/baselines/reference/es6ImportWithoutFromClause.js | 1 + tests/baselines/reference/es6ImportWithoutFromClauseAmd.js | 2 ++ tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js | 1 + .../es6ImportWithoutFromClauseNonInstantiatedModule.js | 1 + .../moduleAugmentationCollidingNamesInAugmentation1.js | 2 ++ .../baselines/reference/moduleAugmentationDeclarationEmit1.js | 1 + .../baselines/reference/moduleAugmentationDeclarationEmit2.js | 1 + .../reference/moduleAugmentationExtendAmbientModule2.js | 1 + tests/baselines/reference/moduleAugmentationGlobal3.js | 1 + tests/baselines/reference/moduleAugmentationGlobal4.js | 2 ++ tests/baselines/reference/moduleAugmentationGlobal5.js | 2 ++ .../reference/moduleAugmentationImportsAndExports1.js | 1 + .../reference/moduleAugmentationImportsAndExports2.js | 1 + .../reference/moduleAugmentationImportsAndExports3.js | 1 + .../reference/moduleAugmentationImportsAndExports5.js | 1 + .../reference/moduleAugmentationImportsAndExports6.js | 1 + .../baselines/reference/moduleAugmentationInAmbientModule5.js | 1 + .../baselines/reference/moduleAugmentationsBundledOutput1.js | 2 ++ tests/baselines/reference/moduleAugmentationsImports1.js | 1 + tests/baselines/reference/moduleAugmentationsImports2.js | 2 ++ tests/baselines/reference/moduleAugmentationsImports3.js | 2 ++ tests/baselines/reference/moduleAugmentationsImports4.js | 2 ++ 23 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index ab0b16947fc..5977c84d7f4 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -698,10 +698,6 @@ namespace ts { } function writeImportDeclaration(node: ImportDeclaration) { - if (!node.importClause && !(node.flags & NodeFlags.Export)) { - // do not write non-exported import declarations that don't have import clauses - return; - } emitJsDocComments(node); if (node.flags & NodeFlags.Export) { write("export "); diff --git a/tests/baselines/reference/es6ImportWithoutFromClause.js b/tests/baselines/reference/es6ImportWithoutFromClause.js index 9666409b924..cc8509baade 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClause.js +++ b/tests/baselines/reference/es6ImportWithoutFromClause.js @@ -17,3 +17,4 @@ import "es6ImportWithoutFromClause_0"; //// [es6ImportWithoutFromClause_0.d.ts] export declare var a: number; //// [es6ImportWithoutFromClause_1.d.ts] +import "es6ImportWithoutFromClause_0"; diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js index 39b6b04464c..ea533a9a963 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js @@ -36,3 +36,5 @@ export declare var a: number; //// [es6ImportWithoutFromClauseAmd_1.d.ts] export declare var b: number; //// [es6ImportWithoutFromClauseAmd_2.d.ts] +import "es6ImportWithoutFromClauseAmd_0"; +import "es6ImportWithoutFromClauseAmd_2"; diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js index c39cd1172a0..d0f7c9fbe65 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js @@ -18,3 +18,4 @@ require("es6ImportWithoutFromClauseInEs5_0"); //// [es6ImportWithoutFromClauseInEs5_0.d.ts] export declare var a: number; //// [es6ImportWithoutFromClauseInEs5_1.d.ts] +import "es6ImportWithoutFromClauseInEs5_0"; diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js index e63dd4bb53a..51bb0f3338d 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js @@ -17,3 +17,4 @@ import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; export interface i { } //// [es6ImportWithoutFromClauseNonInstantiatedModule_1.d.ts] +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; diff --git a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js index 60ba2217349..2e84e1492be 100644 --- a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js +++ b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js @@ -73,3 +73,5 @@ declare module "./observable" { } export {}; //// [main.d.ts] +import "./map1"; +import "./map2"; diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js index 589d0f506e9..7b44fb7a637 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js @@ -66,3 +66,4 @@ declare module "./observable" { } export {}; //// [main.d.ts] +import "./map"; diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js index d8fd65a1464..547d017c502 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js @@ -71,3 +71,4 @@ declare module "./observable" { } export {}; //// [main.d.ts] +import "./map"; diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js index 733f88e6129..2d65953e2a3 100644 --- a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js @@ -63,3 +63,4 @@ declare module "observable" { export {}; //// [main.d.ts] /// +import "./map"; diff --git a/tests/baselines/reference/moduleAugmentationGlobal3.js b/tests/baselines/reference/moduleAugmentationGlobal3.js index 4cff75f5df0..caa080a558c 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal3.js +++ b/tests/baselines/reference/moduleAugmentationGlobal3.js @@ -50,3 +50,4 @@ declare global { } export {}; //// [f3.d.ts] +import "./f2"; diff --git a/tests/baselines/reference/moduleAugmentationGlobal4.js b/tests/baselines/reference/moduleAugmentationGlobal4.js index 11c5d968df2..38f186d0e05 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal4.js +++ b/tests/baselines/reference/moduleAugmentationGlobal4.js @@ -45,3 +45,5 @@ declare global { export { }; export {}; //// [f3.d.ts] +import "./f1"; +import "./f2"; diff --git a/tests/baselines/reference/moduleAugmentationGlobal5.js b/tests/baselines/reference/moduleAugmentationGlobal5.js index 3efdd2dbb98..70c81893bd8 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal5.js +++ b/tests/baselines/reference/moduleAugmentationGlobal5.js @@ -32,3 +32,5 @@ require("B"); //// [f3.d.ts] /// /// +import "A"; +import "B"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.js b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js index 7159e7b5d0c..8e0b7dad19d 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports1.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js @@ -69,3 +69,4 @@ declare module "./f1" { } } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js index 3a4a807a334..498df8ab90e 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js @@ -74,3 +74,4 @@ export declare class B { n: number; } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js index d872a79e985..8d9e69c5076 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js @@ -72,3 +72,4 @@ export declare class B { n: number; } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js index c9b622ccf25..c3cba4c01f8 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js @@ -76,3 +76,4 @@ export declare class B { n: number; } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.js b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js index f0b297720b3..f5aff705eb4 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports6.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js @@ -95,3 +95,4 @@ declare module "./f1" { } } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule5.js b/tests/baselines/reference/moduleAugmentationInAmbientModule5.js index fab9cebb179..2e6503c4774 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule5.js +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule5.js @@ -33,3 +33,4 @@ var y = x.getA().x; //// [f.d.ts] /// +import "array"; diff --git a/tests/baselines/reference/moduleAugmentationsBundledOutput1.js b/tests/baselines/reference/moduleAugmentationsBundledOutput1.js index 92916206e76..504c015bcb8 100644 --- a/tests/baselines/reference/moduleAugmentationsBundledOutput1.js +++ b/tests/baselines/reference/moduleAugmentationsBundledOutput1.js @@ -139,4 +139,6 @@ declare module "m4" { } } declare module "test" { + import "m2"; + import "m4"; } diff --git a/tests/baselines/reference/moduleAugmentationsImports1.js b/tests/baselines/reference/moduleAugmentationsImports1.js index 2c635a0719e..922bb61d952 100644 --- a/tests/baselines/reference/moduleAugmentationsImports1.js +++ b/tests/baselines/reference/moduleAugmentationsImports1.js @@ -101,4 +101,5 @@ declare module "d" { } } declare module "main" { + import "d"; } diff --git a/tests/baselines/reference/moduleAugmentationsImports2.js b/tests/baselines/reference/moduleAugmentationsImports2.js index f70426b49bd..605a07e29e1 100644 --- a/tests/baselines/reference/moduleAugmentationsImports2.js +++ b/tests/baselines/reference/moduleAugmentationsImports2.js @@ -111,4 +111,6 @@ declare module "e" { } } declare module "main" { + import "d"; + import "e"; } diff --git a/tests/baselines/reference/moduleAugmentationsImports3.js b/tests/baselines/reference/moduleAugmentationsImports3.js index 3654583b5c9..0a946f42be3 100644 --- a/tests/baselines/reference/moduleAugmentationsImports3.js +++ b/tests/baselines/reference/moduleAugmentationsImports3.js @@ -98,4 +98,6 @@ declare module "e" { } } declare module "main" { + import "D"; + import "e"; } diff --git a/tests/baselines/reference/moduleAugmentationsImports4.js b/tests/baselines/reference/moduleAugmentationsImports4.js index 9b64016113f..a48bbb04631 100644 --- a/tests/baselines/reference/moduleAugmentationsImports4.js +++ b/tests/baselines/reference/moduleAugmentationsImports4.js @@ -87,4 +87,6 @@ declare module "b" { } } declare module "main" { + import "D"; + import "E"; } From 9582342b9035229f0c248340158613d54841d340 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 2 Feb 2016 17:53:42 -0800 Subject: [PATCH 014/102] Remove unused error message --- src/compiler/diagnosticMessages.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c848ebc3a10..93872e35aae 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1279,10 +1279,6 @@ "category": "Error", "code": 2417 }, - "Type name '{0}' in extends clause does not reference constructor function for '{0}'.": { - "category": "Error", - "code": 2419 - }, "Class '{0}' incorrectly implements interface '{1}'.": { "category": "Error", "code": 2420 From a0782d91ac4e771dc8d24c9eeed795a79a0066bf Mon Sep 17 00:00:00 2001 From: york yao Date: Wed, 3 Feb 2016 10:02:59 +0800 Subject: [PATCH 015/102] fix error message with public class inside namespace --- src/compiler/checker.ts | 4 +- src/compiler/diagnosticMessages.json | 2 +- .../baselines/reference/Protected1.errors.txt | 4 +- .../baselines/reference/Protected2.errors.txt | 4 +- .../importDeclWithClassModifiers.errors.txt | 12 +-- ...ModuleWithStatementsOfEveryKind.errors.txt | 84 +++++++++---------- .../invalidModuleWithVarStatements.errors.txt | 24 +++--- .../parserInterfaceDeclaration3.errors.txt | 4 +- .../parserInterfaceDeclaration4.errors.txt | 4 +- 9 files changed, 71 insertions(+), 71 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 07ec5023d5b..0628e7fd522 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16214,7 +16214,7 @@ namespace ts { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & NodeFlags.Abstract) { if (modifier.kind === SyntaxKind.PrivateKeyword) { @@ -16238,7 +16238,7 @@ namespace ts { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === SyntaxKind.Parameter) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c848ebc3a10..c9329af6494 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -123,7 +123,7 @@ "category": "Error", "code": 1043 }, - "'{0}' modifier cannot appear on a module element.": { + "'{0}' modifier cannot appear on a module or namespace element.": { "category": "Error", "code": 1044 }, diff --git a/tests/baselines/reference/Protected1.errors.txt b/tests/baselines/reference/Protected1.errors.txt index 561e4cfd001..157c9b3263e 100644 --- a/tests/baselines/reference/Protected1.errors.txt +++ b/tests/baselines/reference/Protected1.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module element. +tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module or namespace element. ==== tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts (1 errors) ==== protected class C { ~~~~~~~~~ -!!! error TS1044: 'protected' modifier cannot appear on a module element. +!!! error TS1044: 'protected' modifier cannot appear on a module or namespace element. } \ No newline at end of file diff --git a/tests/baselines/reference/Protected2.errors.txt b/tests/baselines/reference/Protected2.errors.txt index 0f6de4d49ed..7779cb55348 100644 --- a/tests/baselines/reference/Protected2.errors.txt +++ b/tests/baselines/reference/Protected2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module element. +tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts(1,1): error TS1044: 'protected' modifier cannot appear on a module or namespace element. ==== tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts (1 errors) ==== protected module M { ~~~~~~~~~ -!!! error TS1044: 'protected' modifier cannot appear on a module element. +!!! error TS1044: 'protected' modifier cannot appear on a module or namespace element. } \ No newline at end of file diff --git a/tests/baselines/reference/importDeclWithClassModifiers.errors.txt b/tests/baselines/reference/importDeclWithClassModifiers.errors.txt index b7f60881e6e..586eac79b12 100644 --- a/tests/baselines/reference/importDeclWithClassModifiers.errors.txt +++ b/tests/baselines/reference/importDeclWithClassModifiers.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/importDeclWithClassModifiers.ts(5,8): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/compiler/importDeclWithClassModifiers.ts(5,8): error TS1044: 'public' modifier cannot appear on a module or namespace element. tests/cases/compiler/importDeclWithClassModifiers.ts(5,28): error TS2305: Module 'x' has no exported member 'c'. -tests/cases/compiler/importDeclWithClassModifiers.ts(6,8): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/compiler/importDeclWithClassModifiers.ts(6,8): error TS1044: 'private' modifier cannot appear on a module or namespace element. tests/cases/compiler/importDeclWithClassModifiers.ts(6,29): error TS2305: Module 'x' has no exported member 'c'. -tests/cases/compiler/importDeclWithClassModifiers.ts(7,8): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/compiler/importDeclWithClassModifiers.ts(7,8): error TS1044: 'static' modifier cannot appear on a module or namespace element. tests/cases/compiler/importDeclWithClassModifiers.ts(7,28): error TS2305: Module 'x' has no exported member 'c'. @@ -13,17 +13,17 @@ tests/cases/compiler/importDeclWithClassModifiers.ts(7,28): error TS2305: Module } export public import a = x.c; ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. ~ !!! error TS2305: Module 'x' has no exported member 'c'. export private import b = x.c; ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. ~ !!! error TS2305: Module 'x' has no exported member 'c'. export static import c = x.c; ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. ~ !!! error TS2305: Module 'x' has no exported member 'c'. var b: a; diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt index 101ee0124cc..797f3b1fe9a 100644 --- a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt @@ -1,24 +1,24 @@ -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(4,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(6,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(12,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(13,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(15,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(19,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(25,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(29,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(31,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(37,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(38,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(40,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(44,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(50,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(55,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(57,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(63,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(64,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(66,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(70,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(76,5): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(4,5): error TS1044: 'public' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(6,5): error TS1044: 'public' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(12,5): error TS1044: 'public' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(13,5): error TS1044: 'public' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(15,5): error TS1044: 'public' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(19,5): error TS1044: 'public' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(25,5): error TS1044: 'public' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(29,5): error TS1044: 'private' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(31,5): error TS1044: 'private' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(37,5): error TS1044: 'private' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(38,5): error TS1044: 'private' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(40,5): error TS1044: 'private' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(44,5): error TS1044: 'private' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(50,5): error TS1044: 'private' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(55,5): error TS1044: 'static' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(57,5): error TS1044: 'static' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(63,5): error TS1044: 'static' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(64,5): error TS1044: 'static' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(66,5): error TS1044: 'static' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(70,5): error TS1044: 'static' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(76,5): error TS1044: 'static' modifier cannot appear on a module or namespace element. ==== tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts (21 errors) ==== @@ -27,11 +27,11 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOf module Y { public class A { s: string } ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. public class BB extends A { ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. id: number; } } @@ -39,20 +39,20 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOf module Y2 { public class AA { s: T } ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. public interface I { id: number } ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. public class B extends AA implements I { id: number } ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. } module Y3 { public module Module { ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. class A { s: string } } } @@ -60,17 +60,17 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOf module Y4 { public enum Color { Blue, Red } ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. } module YY { private class A { s: string } ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. private class BB extends A { ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. id: number; } } @@ -78,20 +78,20 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOf module YY2 { private class AA { s: T } ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. private interface I { id: number } ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. private class B extends AA implements I { id: number } ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. } module YY3 { private module Module { ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. class A { s: string } } } @@ -99,18 +99,18 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOf module YY4 { private enum Color { Blue, Red } ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. } module YYY { static class A { s: string } ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. static class BB extends A { ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. id: number; } } @@ -118,20 +118,20 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOf module YYY2 { static class AA { s: T } ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. static interface I { id: number } ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. static class B extends AA implements I { id: number } ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. } module YYY3 { static module Module { ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. class A { s: string } } } @@ -139,6 +139,6 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOf module YYY4 { static enum Color { Blue, Red } ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. } \ No newline at end of file diff --git a/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt b/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt index ad8d457670a..347e558eddd 100644 --- a/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt +++ b/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(4,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(8,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(12,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(16,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(20,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(25,5): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(4,5): error TS1044: 'public' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(8,5): error TS1044: 'public' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(12,5): error TS1044: 'static' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(16,5): error TS1044: 'static' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(20,5): error TS1044: 'private' modifier cannot appear on a module or namespace element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(25,5): error TS1044: 'private' modifier cannot appear on a module or namespace element. ==== tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts (6 errors) ==== @@ -12,37 +12,37 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatement module Y { public var x: number = 0; ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. } module Y2 { public function fn(x: string) { } ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. } module Y4 { static var x: number = 0; ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. } module YY { static function fn(x: string) { } ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. } module YY2 { private var x: number = 0; ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. } module YY3 { private function fn(x: string) { } ~~~~~~~ -!!! error TS1044: 'private' modifier cannot appear on a module element. +!!! error TS1044: 'private' modifier cannot appear on a module or namespace element. } \ No newline at end of file diff --git a/tests/baselines/reference/parserInterfaceDeclaration3.errors.txt b/tests/baselines/reference/parserInterfaceDeclaration3.errors.txt index 8e84ca940a4..f074a38bd79 100644 --- a/tests/baselines/reference/parserInterfaceDeclaration3.errors.txt +++ b/tests/baselines/reference/parserInterfaceDeclaration3.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration3.ts(1,1): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration3.ts(1,1): error TS1044: 'public' modifier cannot appear on a module or namespace element. ==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration3.ts (1 errors) ==== public interface I { ~~~~~~ -!!! error TS1044: 'public' modifier cannot appear on a module element. +!!! error TS1044: 'public' modifier cannot appear on a module or namespace element. } \ No newline at end of file diff --git a/tests/baselines/reference/parserInterfaceDeclaration4.errors.txt b/tests/baselines/reference/parserInterfaceDeclaration4.errors.txt index 97a691a5230..aa1fe1aa6e7 100644 --- a/tests/baselines/reference/parserInterfaceDeclaration4.errors.txt +++ b/tests/baselines/reference/parserInterfaceDeclaration4.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration4.ts(1,1): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration4.ts(1,1): error TS1044: 'static' modifier cannot appear on a module or namespace element. ==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration4.ts (1 errors) ==== static interface I { ~~~~~~ -!!! error TS1044: 'static' modifier cannot appear on a module element. +!!! error TS1044: 'static' modifier cannot appear on a module or namespace element. } \ No newline at end of file From 96d82b576c1bcbb72224abb8ac84157d7a2137ed Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 3 Feb 2016 00:03:59 -0800 Subject: [PATCH 016/102] Update README.md --- doc/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/README.md b/doc/README.md index 164fb69ee20..8d7eb3449fa 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,7 +1,9 @@ +# Read This! + This directory contains miscellaneous documentation such as the TypeScript language specification and logo. If you are looking for more introductory material, you might want to take a look at the [TypeScript Handbook](https://github.com/Microsoft/TypeScript-Handbook). # Spec Contributions The specification is first authored as a Microsoft Word (docx) file and then generated into Markdown and PDF formats. -Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new) rather than sent as pull requests. \ No newline at end of file +Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new) rather than sent as pull requests. From c69a9d1a5c6ea3854b333f689135e88d996a2608 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 3 Feb 2016 00:05:09 -0800 Subject: [PATCH 017/102] Update README.md --- lib/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/README.md b/lib/README.md index 583ddf91156..852d449f1e5 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,4 +1,5 @@ -# Read this! +# Read This! -These files are not meant to be edited by hand. -If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory. Running `jake LKG` will then appropriately update the files in this directory. +**These files are not meant to be edited by hand.** +If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory. +Running `jake LKG` will then appropriately update the files in this directory. From f7eac73a6f2e72470c581c62857e4ea7263e871e Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 3 Feb 2016 00:09:38 -0800 Subject: [PATCH 018/102] Recognize `=` as equivalent to `?` in JSDoc signatures Fixes #6811 --- src/compiler/parser.ts | 3 +++ tests/cases/fourslash/jsDocFunctionSignatures2.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures2.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b6ba02b987c..9fcc2ec34d6 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5727,6 +5727,9 @@ namespace ts { function parseJSDocParameter(): ParameterDeclaration { const parameter = createNode(SyntaxKind.Parameter); parameter.type = parseJSDocType(); + if (parseOptional(SyntaxKind.EqualsToken)) { + parameter.questionToken = createNode(SyntaxKind.QuestionToken); + } return finishNode(parameter); } diff --git a/tests/cases/fourslash/jsDocFunctionSignatures2.ts b/tests/cases/fourslash/jsDocFunctionSignatures2.ts new file mode 100644 index 00000000000..174ea7d6560 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures2.ts @@ -0,0 +1,12 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js + +//// /** @type {function(string, boolean=): number} */ +//// var f6; +//// +//// f6('', /**/false) + +goTo.marker(); +verify.currentSignatureHelpIs('f6(p0: string, p1?: boolean): number') From 8aad976c69ef4528f751a0312db2a40ed6a758d8 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 3 Feb 2016 00:18:36 -0800 Subject: [PATCH 019/102] Recognize object literal method JSDoc comments Fixes #6825 --- src/compiler/parser.ts | 4 +-- src/compiler/utilities.ts | 5 +++ .../fourslash/jsDocFunctionSignatures3.ts | 32 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures3.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b6ba02b987c..3ad2cb72507 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3960,7 +3960,7 @@ namespace ts { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } - return finishNode(shorthandDeclaration); + return addJSDocComment(finishNode(shorthandDeclaration)); } else { const propertyAssignment = createNode(SyntaxKind.PropertyAssignment, fullStart); @@ -3969,7 +3969,7 @@ namespace ts { propertyAssignment.questionToken = questionToken; parseExpected(SyntaxKind.ColonToken); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); + return addJSDocComment(finishNode(propertyAssignment)); } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 02b8385d0ff..f794bc81f39 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1220,6 +1220,11 @@ namespace ts { if (isSourceOfAssignmentExpressionStatement) { return node.parent.parent.jsDocComment; } + + const isPropertyAssignmentExpression = node.parent && node.parent.kind === SyntaxKind.PropertyAssignment; + if (isPropertyAssignmentExpression) { + return node.parent.jsDocComment; + } } return undefined; diff --git a/tests/cases/fourslash/jsDocFunctionSignatures3.ts b/tests/cases/fourslash/jsDocFunctionSignatures3.ts new file mode 100644 index 00000000000..3679035d31d --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures3.ts @@ -0,0 +1,32 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js + +//// var someObject = { +//// /** +//// * @param {string} param1 Some string param. +//// * @param {number} parm2 Some number param. +//// */ +//// someMethod: function(param1, param2) { +//// console.log(param1/*1*/); +//// return false; +//// }, +//// /** +//// * @param {number} p1 Some number param. +//// */ +//// otherMethod(p1) { +//// p1/*2*/ +//// } +//// +//// }; + +goTo.marker('1'); +edit.insert('.'); +verify.memberListContains('substr', undefined, undefined, 'method'); +edit.backspace(); + +goTo.marker('2'); +edit.insert('.'); +verify.memberListContains('toFixed', undefined, undefined, 'method'); +edit.backspace(); From 1c7062313d2dde764ea7f7d20f2415b02d8d6fbb Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 3 Feb 2016 00:44:52 -0800 Subject: [PATCH 020/102] Capture `node.parent` --- src/compiler/utilities.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f794bc81f39..8f66e43c1d6 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1212,18 +1212,19 @@ namespace ts { } // Also recognize when the node is the RHS of an assignment expression + const parent = node.parent; const isSourceOfAssignmentExpressionStatement = - node.parent && node.parent.parent && - node.parent.kind === SyntaxKind.BinaryExpression && - (node.parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken && - node.parent.parent.kind === SyntaxKind.ExpressionStatement; + parent && parent.parent && + parent.kind === SyntaxKind.BinaryExpression && + (parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken && + parent.parent.kind === SyntaxKind.ExpressionStatement; if (isSourceOfAssignmentExpressionStatement) { - return node.parent.parent.jsDocComment; + return parent.parent.jsDocComment; } - const isPropertyAssignmentExpression = node.parent && node.parent.kind === SyntaxKind.PropertyAssignment; + const isPropertyAssignmentExpression = parent && parent.kind === SyntaxKind.PropertyAssignment; if (isPropertyAssignmentExpression) { - return node.parent.jsDocComment; + return parent.jsDocComment; } } From 98e8a25d1e5525cd7a9ae6d5b12f620ab658f34a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 3 Feb 2016 06:52:53 -0800 Subject: [PATCH 021/102] Addressing CR feedback --- src/compiler/parser.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 77f50a9bd87..fa17864166d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2464,9 +2464,9 @@ namespace ts { } if (token === SyntaxKind.OpenBracketToken || token === SyntaxKind.OpenBraceToken) { // Return true if we can parse an array or object binding pattern with no errors - const count = parseDiagnostics.length; + const previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); - return count === parseDiagnostics.length; + return previousErrorCount === parseDiagnostics.length; } return false; } @@ -2492,7 +2492,7 @@ namespace ts { if (token === SyntaxKind.CloseParenToken) { nextToken(); if (token === SyntaxKind.EqualsGreaterThanToken) { - // ( id ) => + // ( xxx ) => return true; } } From d47097f009ce63eca1021ce646aaa04cab19fa64 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 3 Feb 2016 10:05:58 -0800 Subject: [PATCH 022/102] Use different syntax kind here --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 9fcc2ec34d6..056dd375374 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5728,7 +5728,7 @@ namespace ts { const parameter = createNode(SyntaxKind.Parameter); parameter.type = parseJSDocType(); if (parseOptional(SyntaxKind.EqualsToken)) { - parameter.questionToken = createNode(SyntaxKind.QuestionToken); + parameter.questionToken = createNode(SyntaxKind.EqualsToken); } return finishNode(parameter); } From 98b8af62e7f2afd42f70de286c8a45eb00651428 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 3 Feb 2016 13:45:36 -0800 Subject: [PATCH 023/102] Update README.md --- doc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/README.md b/doc/README.md index 8d7eb3449fa..cfc97fedbe9 100644 --- a/doc/README.md +++ b/doc/README.md @@ -6,4 +6,4 @@ If you are looking for more introductory material, you might want to take a look # Spec Contributions The specification is first authored as a Microsoft Word (docx) file and then generated into Markdown and PDF formats. -Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new) rather than sent as pull requests. +Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that **any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new)** rather than sent as pull requests. From 10522f9eee43f9515f2ced6f7a46ddd5180eb162 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 3 Feb 2016 14:16:09 -0800 Subject: [PATCH 024/102] Add flag to emit modules in loose mode --- src/compiler/commandLineParser.ts | 5 +++ src/compiler/diagnosticMessages.json | 38 +++++++++++-------- src/compiler/emitter.ts | 8 ++-- src/compiler/types.ts | 1 + .../reference/emitModulesInLooseMode_amd.js | 8 ++++ .../emitModulesInLooseMode_amd.symbols | 5 +++ .../emitModulesInLooseMode_amd.types | 6 +++ .../emitModulesInLooseMode_commonjs.js | 6 +++ .../emitModulesInLooseMode_commonjs.symbols | 5 +++ .../emitModulesInLooseMode_commonjs.types | 6 +++ .../reference/emitModulesInLooseMode_es6.js | 6 +++ .../emitModulesInLooseMode_es6.symbols | 5 +++ .../emitModulesInLooseMode_es6.types | 6 +++ .../emitModulesInLooseMode_system.js | 15 ++++++++ .../emitModulesInLooseMode_system.symbols | 5 +++ .../emitModulesInLooseMode_system.types | 6 +++ .../reference/emitModulesInLooseMode_umd.js | 15 ++++++++ .../emitModulesInLooseMode_umd.symbols | 5 +++ .../emitModulesInLooseMode_umd.types | 6 +++ .../compiler/emitModulesInLooseMode_amd.ts | 4 ++ .../emitModulesInLooseMode_commonjs.ts | 4 ++ .../compiler/emitModulesInLooseMode_es6.ts | 5 +++ .../compiler/emitModulesInLooseMode_system.ts | 4 ++ .../compiler/emitModulesInLooseMode_umd.ts | 4 ++ 24 files changed, 158 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/emitModulesInLooseMode_amd.js create mode 100644 tests/baselines/reference/emitModulesInLooseMode_amd.symbols create mode 100644 tests/baselines/reference/emitModulesInLooseMode_amd.types create mode 100644 tests/baselines/reference/emitModulesInLooseMode_commonjs.js create mode 100644 tests/baselines/reference/emitModulesInLooseMode_commonjs.symbols create mode 100644 tests/baselines/reference/emitModulesInLooseMode_commonjs.types create mode 100644 tests/baselines/reference/emitModulesInLooseMode_es6.js create mode 100644 tests/baselines/reference/emitModulesInLooseMode_es6.symbols create mode 100644 tests/baselines/reference/emitModulesInLooseMode_es6.types create mode 100644 tests/baselines/reference/emitModulesInLooseMode_system.js create mode 100644 tests/baselines/reference/emitModulesInLooseMode_system.symbols create mode 100644 tests/baselines/reference/emitModulesInLooseMode_system.types create mode 100644 tests/baselines/reference/emitModulesInLooseMode_umd.js create mode 100644 tests/baselines/reference/emitModulesInLooseMode_umd.symbols create mode 100644 tests/baselines/reference/emitModulesInLooseMode_umd.types create mode 100644 tests/cases/compiler/emitModulesInLooseMode_amd.ts create mode 100644 tests/cases/compiler/emitModulesInLooseMode_commonjs.ts create mode 100644 tests/cases/compiler/emitModulesInLooseMode_es6.ts create mode 100644 tests/cases/compiler/emitModulesInLooseMode_system.ts create mode 100644 tests/cases/compiler/emitModulesInLooseMode_umd.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d5bf95a6405..7d635c2aaf5 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -320,6 +320,11 @@ namespace ts { name: "allowSyntheticDefaultImports", type: "boolean", description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "emitModulesInLooseMode", + type: "boolean", + description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output } ]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b8ae833e5ab..5b93f61bb90 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1,4 +1,4 @@ - { +{ "Unterminated string literal.": { "category": "Error", "code": 1002 @@ -2187,6 +2187,7 @@ "category": "Error", "code": 5062 }, + "Concatenate and emit output to single file.": { "category": "Message", "code": 6001 @@ -2231,10 +2232,10 @@ "category": "Message", "code": 6011 }, - "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)": { - "category": "Message", - "code": 6015 - }, + "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)": { + "category": "Message", + "code": 6015 + }, "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'": { "category": "Message", "code": 6016 @@ -2571,6 +2572,11 @@ "category": "Message", "code": 6111 }, + "Do not emit 'use strict' directives in module output.": { + "category": "Message", + "code": 6112 + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 @@ -2757,23 +2763,23 @@ "code": 17004 }, "A constructor cannot contain a 'super' call when its class extends 'null'": { - "category": "Error", - "code": 17005 + "category": "Error", + "code": 17005 }, "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": { - "category": "Error", - "code": 17006 + "category": "Error", + "code": 17006 }, "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": { - "category": "Error", - "code": 17007 + "category": "Error", + "code": 17007 }, "JSX element '{0}' has no corresponding closing tag.": { - "category": "Error", - "code": 17008 + "category": "Error", + "code": 17008 }, "'super' must be called before accessing 'this' in the constructor of a derived class.": { - "category": "Error", - "code": 17009 + "category": "Error", + "code": 17009 } -} +} \ No newline at end of file diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e86d86603b4..92cb3334f63 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7179,7 +7179,7 @@ const _super = (function (geti, seti) { write(`], function(${exportFunctionForFile}, ${contextObjectForFile}) {`); writeLine(); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.emitModulesInLooseMode); writeLine(); write(`var __moduleName = ${contextObjectForFile} && ${contextObjectForFile}.id;`); writeLine(); @@ -7285,7 +7285,7 @@ const _super = (function (geti, seti) { writeModuleName(node, emitRelativePathAsModuleName); emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/!compilerOptions.emitModulesInLooseMode); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -7297,7 +7297,7 @@ const _super = (function (geti, seti) { } function emitCommonJSModule(node: SourceFile) { - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.emitModulesInLooseMode); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -7326,7 +7326,7 @@ const _super = (function (geti, seti) { })(`); emitAMDFactoryHeader(dependencyNames); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.emitModulesInLooseMode); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5545fbd162e..97cf2fff3b5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2422,6 +2422,7 @@ namespace ts { traceModuleResolution?: boolean; allowSyntheticDefaultImports?: boolean; allowJs?: boolean; + emitModulesInLooseMode?: boolean; /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. diff --git a/tests/baselines/reference/emitModulesInLooseMode_amd.js b/tests/baselines/reference/emitModulesInLooseMode_amd.js new file mode 100644 index 00000000000..a93ca62de0e --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_amd.js @@ -0,0 +1,8 @@ +//// [emitModulesInLooseMode_amd.ts] + +export var x = 0; + +//// [emitModulesInLooseMode_amd.js] +define(["require", "exports"], function (require, exports) { + exports.x = 0; +}); diff --git a/tests/baselines/reference/emitModulesInLooseMode_amd.symbols b/tests/baselines/reference/emitModulesInLooseMode_amd.symbols new file mode 100644 index 00000000000..d76fea8b7b8 --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_amd.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitModulesInLooseMode_amd.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitModulesInLooseMode_amd.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitModulesInLooseMode_amd.types b/tests/baselines/reference/emitModulesInLooseMode_amd.types new file mode 100644 index 00000000000..1c070cc95fa --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_amd.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitModulesInLooseMode_amd.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitModulesInLooseMode_commonjs.js b/tests/baselines/reference/emitModulesInLooseMode_commonjs.js new file mode 100644 index 00000000000..be24cdf6b91 --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_commonjs.js @@ -0,0 +1,6 @@ +//// [emitModulesInLooseMode_commonjs.ts] + +export var x = 0; + +//// [emitModulesInLooseMode_commonjs.js] +exports.x = 0; diff --git a/tests/baselines/reference/emitModulesInLooseMode_commonjs.symbols b/tests/baselines/reference/emitModulesInLooseMode_commonjs.symbols new file mode 100644 index 00000000000..225286c74de --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_commonjs.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitModulesInLooseMode_commonjs.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitModulesInLooseMode_commonjs.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitModulesInLooseMode_commonjs.types b/tests/baselines/reference/emitModulesInLooseMode_commonjs.types new file mode 100644 index 00000000000..b37bb9667ab --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_commonjs.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitModulesInLooseMode_commonjs.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitModulesInLooseMode_es6.js b/tests/baselines/reference/emitModulesInLooseMode_es6.js new file mode 100644 index 00000000000..95cc14ff609 --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_es6.js @@ -0,0 +1,6 @@ +//// [emitModulesInLooseMode_es6.ts] + +export var x = 0; + +//// [emitModulesInLooseMode_es6.js] +export var x = 0; diff --git a/tests/baselines/reference/emitModulesInLooseMode_es6.symbols b/tests/baselines/reference/emitModulesInLooseMode_es6.symbols new file mode 100644 index 00000000000..4f3c073f7ee --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitModulesInLooseMode_es6.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitModulesInLooseMode_es6.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitModulesInLooseMode_es6.types b/tests/baselines/reference/emitModulesInLooseMode_es6.types new file mode 100644 index 00000000000..84631ede00f --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitModulesInLooseMode_es6.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitModulesInLooseMode_system.js b/tests/baselines/reference/emitModulesInLooseMode_system.js new file mode 100644 index 00000000000..4cf401a554d --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_system.js @@ -0,0 +1,15 @@ +//// [emitModulesInLooseMode_system.ts] + +export var x = 0; + +//// [emitModulesInLooseMode_system.js] +System.register([], function(exports_1, context_1) { + var __moduleName = context_1 && context_1.id; + var x; + return { + setters:[], + execute: function() { + exports_1("x", x = 0); + } + } +}); diff --git a/tests/baselines/reference/emitModulesInLooseMode_system.symbols b/tests/baselines/reference/emitModulesInLooseMode_system.symbols new file mode 100644 index 00000000000..0682b2b648f --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_system.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitModulesInLooseMode_system.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitModulesInLooseMode_system.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitModulesInLooseMode_system.types b/tests/baselines/reference/emitModulesInLooseMode_system.types new file mode 100644 index 00000000000..429908c1de4 --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_system.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitModulesInLooseMode_system.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitModulesInLooseMode_umd.js b/tests/baselines/reference/emitModulesInLooseMode_umd.js new file mode 100644 index 00000000000..327962d18f2 --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_umd.js @@ -0,0 +1,15 @@ +//// [emitModulesInLooseMode_umd.ts] + +export var x = 0; + +//// [emitModulesInLooseMode_umd.js] +(function (factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(["require", "exports"], factory); + } +})(function (require, exports) { + exports.x = 0; +}); diff --git a/tests/baselines/reference/emitModulesInLooseMode_umd.symbols b/tests/baselines/reference/emitModulesInLooseMode_umd.symbols new file mode 100644 index 00000000000..86c9e9b200c --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_umd.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitModulesInLooseMode_umd.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitModulesInLooseMode_umd.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitModulesInLooseMode_umd.types b/tests/baselines/reference/emitModulesInLooseMode_umd.types new file mode 100644 index 00000000000..98a32838eb6 --- /dev/null +++ b/tests/baselines/reference/emitModulesInLooseMode_umd.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitModulesInLooseMode_umd.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/cases/compiler/emitModulesInLooseMode_amd.ts b/tests/cases/compiler/emitModulesInLooseMode_amd.ts new file mode 100644 index 00000000000..7c3394bebae --- /dev/null +++ b/tests/cases/compiler/emitModulesInLooseMode_amd.ts @@ -0,0 +1,4 @@ +// @module: amd +// @emitModulesInLooseMode: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitModulesInLooseMode_commonjs.ts b/tests/cases/compiler/emitModulesInLooseMode_commonjs.ts new file mode 100644 index 00000000000..761f1f6ea9f --- /dev/null +++ b/tests/cases/compiler/emitModulesInLooseMode_commonjs.ts @@ -0,0 +1,4 @@ +// @module: commonjs +// @emitModulesInLooseMode: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitModulesInLooseMode_es6.ts b/tests/cases/compiler/emitModulesInLooseMode_es6.ts new file mode 100644 index 00000000000..22c4368629f --- /dev/null +++ b/tests/cases/compiler/emitModulesInLooseMode_es6.ts @@ -0,0 +1,5 @@ +// @module: es6 +// @target: es6 +// @emitModulesInLooseMode: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitModulesInLooseMode_system.ts b/tests/cases/compiler/emitModulesInLooseMode_system.ts new file mode 100644 index 00000000000..0face8fabca --- /dev/null +++ b/tests/cases/compiler/emitModulesInLooseMode_system.ts @@ -0,0 +1,4 @@ +// @module: system +// @emitModulesInLooseMode: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitModulesInLooseMode_umd.ts b/tests/cases/compiler/emitModulesInLooseMode_umd.ts new file mode 100644 index 00000000000..a6a3559986f --- /dev/null +++ b/tests/cases/compiler/emitModulesInLooseMode_umd.ts @@ -0,0 +1,4 @@ +// @module: umd +// @emitModulesInLooseMode: true + +export var x = 0; \ No newline at end of file From daa70e3f23ee9ad91129b4e71ba8dc0007db0962 Mon Sep 17 00:00:00 2001 From: Jesse Schalken Date: Thu, 4 Feb 2016 11:38:21 +1100 Subject: [PATCH 025/102] Fix Stack Overflow and Gitter links in CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1dba1281dd7..7a99bf318d2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ Issues that ask questions answered in the FAQ will be closed without elaboration ## 3. Do you have a question? The issue tracker is for **issues**, in other words, bugs and suggestions. -If you have a *question*, please use [http://stackoverflow.com/questions/tagged/typescript](Stack Overflow), [https://gitter.im/Microsoft/TypeScript](Gitter), your favorite search engine, or other resources. +If you have a *question*, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/typescript), [Gitter](https://gitter.im/Microsoft/TypeScript), your favorite search engine, or other resources. Due to increased traffic, we can no longer answer questions in the issue tracker. ## 4. Did you find a bug? From 2c24f81561778b88248ef6c28482ad83fddf0488 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 3 Feb 2016 21:43:31 -0800 Subject: [PATCH 026/102] added tests --- .../baselines/reference/keepImportsInDts1.js | 16 +++++++++++++ .../reference/keepImportsInDts1.symbols | 6 +++++ .../reference/keepImportsInDts1.types | 6 +++++ .../baselines/reference/keepImportsInDts2.js | 22 +++++++++++++++++ .../reference/keepImportsInDts2.symbols | 6 +++++ .../reference/keepImportsInDts2.types | 6 +++++ .../baselines/reference/keepImportsInDts3.js | 24 +++++++++++++++++++ .../reference/keepImportsInDts3.symbols | 6 +++++ .../reference/keepImportsInDts3.types | 6 +++++ .../baselines/reference/keepImportsInDts4.js | 24 +++++++++++++++++++ .../reference/keepImportsInDts4.symbols | 6 +++++ .../reference/keepImportsInDts4.types | 6 +++++ .../baselines/reference/noErrorOnEmptyDts.js | 13 ---------- .../reference/noErrorOnEmptyDts.symbols | 8 ------- .../reference/noErrorOnEmptyDts.types | 8 ------- tests/cases/compiler/keepImportsInDts1.ts | 7 ++++++ tests/cases/compiler/keepImportsInDts2.ts | 7 ++++++ tests/cases/compiler/keepImportsInDts3.ts | 8 +++++++ tests/cases/compiler/keepImportsInDts4.ts | 8 +++++++ tests/cases/compiler/noErrorOnEmptyDts.ts | 8 ------- 20 files changed, 164 insertions(+), 37 deletions(-) create mode 100644 tests/baselines/reference/keepImportsInDts1.js create mode 100644 tests/baselines/reference/keepImportsInDts1.symbols create mode 100644 tests/baselines/reference/keepImportsInDts1.types create mode 100644 tests/baselines/reference/keepImportsInDts2.js create mode 100644 tests/baselines/reference/keepImportsInDts2.symbols create mode 100644 tests/baselines/reference/keepImportsInDts2.types create mode 100644 tests/baselines/reference/keepImportsInDts3.js create mode 100644 tests/baselines/reference/keepImportsInDts3.symbols create mode 100644 tests/baselines/reference/keepImportsInDts3.types create mode 100644 tests/baselines/reference/keepImportsInDts4.js create mode 100644 tests/baselines/reference/keepImportsInDts4.symbols create mode 100644 tests/baselines/reference/keepImportsInDts4.types delete mode 100644 tests/baselines/reference/noErrorOnEmptyDts.js delete mode 100644 tests/baselines/reference/noErrorOnEmptyDts.symbols delete mode 100644 tests/baselines/reference/noErrorOnEmptyDts.types create mode 100644 tests/cases/compiler/keepImportsInDts1.ts create mode 100644 tests/cases/compiler/keepImportsInDts2.ts create mode 100644 tests/cases/compiler/keepImportsInDts3.ts create mode 100644 tests/cases/compiler/keepImportsInDts4.ts delete mode 100644 tests/cases/compiler/noErrorOnEmptyDts.ts diff --git a/tests/baselines/reference/keepImportsInDts1.js b/tests/baselines/reference/keepImportsInDts1.js new file mode 100644 index 00000000000..8189ce43088 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts1.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/keepImportsInDts1.ts] //// + +//// [test.d.ts] + +export {}; +//// [main.ts] +import "test" + +//// [main.js] +define(["require", "exports", "test"], function (require, exports) { + "use strict"; +}); + + +//// [main.d.ts] +import "test"; diff --git a/tests/baselines/reference/keepImportsInDts1.symbols b/tests/baselines/reference/keepImportsInDts1.symbols new file mode 100644 index 00000000000..92bd84c2088 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts1.symbols @@ -0,0 +1,6 @@ +=== c:/test.d.ts === + +No type information for this code.export {}; +No type information for this code.=== c:/app/main.ts === +import "test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts1.types b/tests/baselines/reference/keepImportsInDts1.types new file mode 100644 index 00000000000..92bd84c2088 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts1.types @@ -0,0 +1,6 @@ +=== c:/test.d.ts === + +No type information for this code.export {}; +No type information for this code.=== c:/app/main.ts === +import "test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts2.js b/tests/baselines/reference/keepImportsInDts2.js new file mode 100644 index 00000000000..559b4814526 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts2.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/keepImportsInDts2.ts] //// + +//// [test.ts] + +export {}; +//// [main.ts] +import "./folder/test" + +//// [test.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [main.js] +define(["require", "exports", "./folder/test"], function (require, exports) { + "use strict"; +}); + + +//// [test.d.ts] +export { }; +//// [main.d.ts] +import "./folder/test"; diff --git a/tests/baselines/reference/keepImportsInDts2.symbols b/tests/baselines/reference/keepImportsInDts2.symbols new file mode 100644 index 00000000000..ce6f4c7c168 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts2.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/folder/test.ts === + +No type information for this code.export {}; +No type information for this code.=== tests/cases/compiler/main.ts === +import "./folder/test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts2.types b/tests/baselines/reference/keepImportsInDts2.types new file mode 100644 index 00000000000..ce6f4c7c168 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts2.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/folder/test.ts === + +No type information for this code.export {}; +No type information for this code.=== tests/cases/compiler/main.ts === +import "./folder/test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts3.js b/tests/baselines/reference/keepImportsInDts3.js new file mode 100644 index 00000000000..e48ba693726 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts3.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/keepImportsInDts3.ts] //// + +//// [test.ts] + +export {}; +//// [main.ts] +import "test" + +//// [outputfile.js] +define("test", ["require", "exports"], function (require, exports) { + "use strict"; +}); +define("app/main", ["require", "exports", "test"], function (require, exports) { + "use strict"; +}); + + +//// [outputfile.d.ts] +declare module "test" { + export { }; +} +declare module "app/main" { + import "test"; +} diff --git a/tests/baselines/reference/keepImportsInDts3.symbols b/tests/baselines/reference/keepImportsInDts3.symbols new file mode 100644 index 00000000000..29c4a4e44b4 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts3.symbols @@ -0,0 +1,6 @@ +=== c:/test.ts === + +No type information for this code.export {}; +No type information for this code.=== c:/app/main.ts === +import "test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts3.types b/tests/baselines/reference/keepImportsInDts3.types new file mode 100644 index 00000000000..29c4a4e44b4 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts3.types @@ -0,0 +1,6 @@ +=== c:/test.ts === + +No type information for this code.export {}; +No type information for this code.=== c:/app/main.ts === +import "test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts4.js b/tests/baselines/reference/keepImportsInDts4.js new file mode 100644 index 00000000000..badec87984e --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts4.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/keepImportsInDts4.ts] //// + +//// [test.ts] + +export {}; +//// [main.ts] +import "./folder/test" + +//// [outputfile.js] +define("folder/test", ["require", "exports"], function (require, exports) { + "use strict"; +}); +define("main", ["require", "exports", "folder/test"], function (require, exports) { + "use strict"; +}); + + +//// [outputfile.d.ts] +declare module "folder/test" { + export { }; +} +declare module "main" { + import "folder/test"; +} diff --git a/tests/baselines/reference/keepImportsInDts4.symbols b/tests/baselines/reference/keepImportsInDts4.symbols new file mode 100644 index 00000000000..ce6f4c7c168 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts4.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/folder/test.ts === + +No type information for this code.export {}; +No type information for this code.=== tests/cases/compiler/main.ts === +import "./folder/test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts4.types b/tests/baselines/reference/keepImportsInDts4.types new file mode 100644 index 00000000000..ce6f4c7c168 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts4.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/folder/test.ts === + +No type information for this code.export {}; +No type information for this code.=== tests/cases/compiler/main.ts === +import "./folder/test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/noErrorOnEmptyDts.js b/tests/baselines/reference/noErrorOnEmptyDts.js deleted file mode 100644 index 83595e3d2ad..00000000000 --- a/tests/baselines/reference/noErrorOnEmptyDts.js +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/noErrorOnEmptyDts.ts] //// - -//// [test.d.ts] - - -// comment - -//// [main.ts] -import "test" - -//// [main.js] -"use strict"; -require("test"); diff --git a/tests/baselines/reference/noErrorOnEmptyDts.symbols b/tests/baselines/reference/noErrorOnEmptyDts.symbols deleted file mode 100644 index 78446a19fb8..00000000000 --- a/tests/baselines/reference/noErrorOnEmptyDts.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== c:/node_modules/test.d.ts === - -No type information for this code. -No type information for this code.// comment -No type information for this code. -No type information for this code.=== c:/app/main.ts === -import "test" -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/noErrorOnEmptyDts.types b/tests/baselines/reference/noErrorOnEmptyDts.types deleted file mode 100644 index 78446a19fb8..00000000000 --- a/tests/baselines/reference/noErrorOnEmptyDts.types +++ /dev/null @@ -1,8 +0,0 @@ -=== c:/node_modules/test.d.ts === - -No type information for this code. -No type information for this code.// comment -No type information for this code. -No type information for this code.=== c:/app/main.ts === -import "test" -No type information for this code. \ No newline at end of file diff --git a/tests/cases/compiler/keepImportsInDts1.ts b/tests/cases/compiler/keepImportsInDts1.ts new file mode 100644 index 00000000000..50bdc5830a8 --- /dev/null +++ b/tests/cases/compiler/keepImportsInDts1.ts @@ -0,0 +1,7 @@ +// @module: amd +// @declaration: true + +// @filename: c:/test.d.ts +export {}; +// @filename: c:/app/main.ts +import "test" \ No newline at end of file diff --git a/tests/cases/compiler/keepImportsInDts2.ts b/tests/cases/compiler/keepImportsInDts2.ts new file mode 100644 index 00000000000..407526d7595 --- /dev/null +++ b/tests/cases/compiler/keepImportsInDts2.ts @@ -0,0 +1,7 @@ +// @module: amd +// @declaration: true + +// @filename: folder/test.ts +export {}; +// @filename: main.ts +import "./folder/test" \ No newline at end of file diff --git a/tests/cases/compiler/keepImportsInDts3.ts b/tests/cases/compiler/keepImportsInDts3.ts new file mode 100644 index 00000000000..cdd83dce132 --- /dev/null +++ b/tests/cases/compiler/keepImportsInDts3.ts @@ -0,0 +1,8 @@ +// @module: amd +// @declaration: true +// @out: outputfile.js + +// @filename: c:/test.ts +export {}; +// @filename: c:/app/main.ts +import "test" \ No newline at end of file diff --git a/tests/cases/compiler/keepImportsInDts4.ts b/tests/cases/compiler/keepImportsInDts4.ts new file mode 100644 index 00000000000..272932be488 --- /dev/null +++ b/tests/cases/compiler/keepImportsInDts4.ts @@ -0,0 +1,8 @@ +// @module: amd +// @declaration: true +// @out: outputfile.js + +// @filename: folder/test.ts +export {}; +// @filename: main.ts +import "./folder/test" \ No newline at end of file diff --git a/tests/cases/compiler/noErrorOnEmptyDts.ts b/tests/cases/compiler/noErrorOnEmptyDts.ts deleted file mode 100644 index 1266ea2bd75..00000000000 --- a/tests/cases/compiler/noErrorOnEmptyDts.ts +++ /dev/null @@ -1,8 +0,0 @@ -// @module: commonjs - -// @filename: c:/node_modules/test.d.ts - -// comment - -// @filename: c:/app/main.ts -import "test" \ No newline at end of file From dbcfe110f1c82f0b247e186f68c95ab5afc5f999 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 3 Feb 2016 23:48:24 -0800 Subject: [PATCH 027/102] propagate back assignments to block scoped binding from the loop body --- src/compiler/checker.ts | 44 +++ src/compiler/emitter.ts | 148 +++++++-- src/compiler/types.ts | 1 + .../blockScopedBindingsReassignedInLoop1.js | 23 ++ ...ockScopedBindingsReassignedInLoop1.symbols | 17 + ...blockScopedBindingsReassignedInLoop1.types | 32 ++ .../blockScopedBindingsReassignedInLoop2.js | 128 ++++++++ ...ockScopedBindingsReassignedInLoop2.symbols | 98 ++++++ ...blockScopedBindingsReassignedInLoop2.types | 160 ++++++++++ .../blockScopedBindingsReassignedInLoop3.js | 259 +++++++++++++++ ...ockScopedBindingsReassignedInLoop3.symbols | 203 ++++++++++++ ...blockScopedBindingsReassignedInLoop3.types | 301 ++++++++++++++++++ .../blockScopedBindingsReassignedInLoop4.js | 36 +++ ...ockScopedBindingsReassignedInLoop4.symbols | 28 ++ ...blockScopedBindingsReassignedInLoop4.types | 43 +++ .../blockScopedBindingsReassignedInLoop5.js | 29 ++ ...ockScopedBindingsReassignedInLoop5.symbols | 23 ++ ...blockScopedBindingsReassignedInLoop5.types | 37 +++ .../blockScopedBindingsReassignedInLoop6.js | 78 +++++ ...ockScopedBindingsReassignedInLoop6.symbols | 74 +++++ ...blockScopedBindingsReassignedInLoop6.types | 110 +++++++ .../reference/nestedBlockScopedBindings3.js | 8 + .../reference/nestedBlockScopedBindings4.js | 16 + .../reference/nestedBlockScopedBindings5.js | 12 + .../reference/nestedBlockScopedBindings6.js | 8 + .../blockScopedBindingsReassignedInLoop1.ts | 7 + .../blockScopedBindingsReassignedInLoop2.ts | 41 +++ .../blockScopedBindingsReassignedInLoop3.ts | 91 ++++++ .../blockScopedBindingsReassignedInLoop4.ts | 11 + .../blockScopedBindingsReassignedInLoop5.ts | 7 + .../blockScopedBindingsReassignedInLoop6.ts | 28 ++ 31 files changed, 2081 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop1.symbols create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop2.symbols create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop3.symbols create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop4.symbols create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop5.symbols create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop6.symbols create mode 100644 tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types create mode 100644 tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts create mode 100644 tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts create mode 100644 tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts create mode 100644 tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts create mode 100644 tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts create mode 100644 tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0628e7fd522..65cb3df785f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7264,6 +7264,15 @@ namespace ts { // mark iteration statement as containing block-scoped binding captured in some function getNodeLinks(current).flags |= NodeCheckFlags.LoopWithCapturedBlockScopedBinding; } + + // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. + // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. + if (container.kind === SyntaxKind.ForStatement && + getAncestor(symbol.valueDeclaration, SyntaxKind.VariableDeclarationList).parent === container && + isAssignedInBodyOfForStatement(node, container)) { + getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.NeedsLoopOutParameter; + } + // set 'declared inside loop' bit on the block-scoped binding getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop; } @@ -7273,6 +7282,41 @@ namespace ts { } } + function isAssignedInBodyOfForStatement(node: Identifier, container: ForStatement): boolean { + let current: Node = node; + // skip parenthesized nodes + while (current.parent.kind === SyntaxKind.ParenthesizedExpression) { + current = current.parent; + } + + // check if node is used as LHS in some assignment expression + let isAssigned = false; + if (current.parent.kind === SyntaxKind.BinaryExpression) { + isAssigned = (current.parent).left === current && isAssignmentOperator((current.parent).operatorToken.kind); + } + + if ((current.parent.kind === SyntaxKind.PrefixUnaryExpression || current.parent.kind === SyntaxKind.PostfixUnaryExpression)) { + const expr = current.parent; + isAssigned = expr.operator === SyntaxKind.PlusPlusToken || expr.operator === SyntaxKind.MinusMinusToken; + } + + if (!isAssigned) { + return false; + } + + // at this point we know that node is the target of assignment + // now check that modification happens inside the statement part of the ForStatement + while (current !== container) { + if (current === container.statement) { + return true; + } + else { + current = current.parent; + } + } + return false; + } + function captureLexicalThis(node: Node, container: Node): void { getNodeLinks(node).flags |= NodeCheckFlags.LexicalThis; if (container.kind === SyntaxKind.PropertyDeclaration || container.kind === SyntaxKind.Constructor) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e86d86603b4..be6a4dc36fc 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -287,6 +287,54 @@ namespace ts { _i = 0x10000000, // Use/preference flag for '_i' } + const enum CopyDirection { + ToOriginal, + ToOutParameter + } + + /** + * If loop contains block scoped binding captured in some function then loop body is converted to a function. + * Lexical bindings declared in loop initializer will be passed into the loop body function as parameters, + * however if this binding is modified inside the body - this new value should be propagated back to the original binding. + * This is done by declaring new variable (out parameter holder) outside of the loop for every binding that is reassigned inside the body. + * On every iteration this variable is initialized with value of corresponding binding. + * At every point where control flow leaves the loop either explicitly (break/continue) or implicitly (at the end of loop body) + * we copy the value inside the loop to the out parameter holder. + * + * for (let x;;) { + * let a = 1; + * let b = () => a; + * x++ + * if (...) break; + * ... + * } + * + * will be converted to + * + * var out_x; + * var loop = function(x) { + * var a = 1; + * var b = function() { return a; } + * x++; + * if (...) return out_x = x, "break"; + * ... + * out_x = x; + * } + * for (var x;;) { + * out_x = x; + * var state = loop(x); + * x = out_x; + * if (state === "break") break; + * } + * + * NOTE: values to out parameters are not copies if loop is abrupted with 'return' - in this case this will end the entire enclosing function + * so nobody can observe this new value. + */ + interface LoopOutParameter { + originalName: Identifier; + outParamName: string; + } + // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult { // emit output for the __extends helper function @@ -419,6 +467,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge * for (var x;;) loop(x); */ hoistedLocalVariables?: Identifier[]; + + /** + * List of loop out parameters - detailed descripion can be found in the comment to LoopOutParameter + */ + loopOutParameters?: LoopOutParameter[]; } function setLabeledJump(state: ConvertedLoopState, isBreak: boolean, labelText: string, labelMarker: string): void { @@ -2968,11 +3021,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } let loopParameters: string[]; + let loopOutParameters: LoopOutParameter[]; if (loopInitializer && (getCombinedNodeFlags(loopInitializer) & NodeFlags.BlockScoped)) { // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters loopParameters = []; for (const varDeclaration of loopInitializer.declarations) { - collectNames(varDeclaration.name); + processVariableDeclaration(varDeclaration.name); } } @@ -2982,14 +3036,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge writeLine(); write(`var ${functionName} = function(${paramList})`); - if (!bodyIsBlock) { - write(" {"); - writeLine(); - increaseIndent(); - } - const convertedOuterLoopState = convertedLoopState; - convertedLoopState = {}; + convertedLoopState = { loopOutParameters }; if (convertedOuterLoopState) { // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. @@ -3013,16 +3061,38 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } } - emitEmbeddedStatement(node.statement); + write(" {"); + writeLine(); + increaseIndent(); - if (!bodyIsBlock) { - decreaseIndent(); - writeLine(); - write("}"); + if (bodyIsBlock) { + emitLines((node.statement).statements); } - write(";"); + else { + emit(node.statement); + } + + writeLine(); + // end of loop body -> copy out parameter + copyLoopOutParameters(convertedLoopState, CopyDirection.ToOutParameter, /*emitAsStatements*/true); + + decreaseIndent(); + writeLine(); + write("};"); writeLine(); + if (loopOutParameters) { + // declare variables to hold out params for loop body + write(`var `); + for (let i = 0; i < loopOutParameters.length; i++) { + if (i !== 0) { + write(", "); + } + write(loopOutParameters[i].outParamName); + } + write(";"); + writeLine(); + } if (convertedLoopState.argumentsName) { // if alias for arguments is set if (convertedOuterLoopState) { @@ -3086,14 +3156,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge return { functionName, paramList, state: currentLoopState }; - function collectNames(name: Identifier | BindingPattern): void { + function processVariableDeclaration(name: Identifier | BindingPattern): void { if (name.kind === SyntaxKind.Identifier) { - const nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(name) ? getGeneratedNameForNode(name) : (name).text; + const nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(name) + ? getGeneratedNameForNode(name) + : (name).text; + loopParameters.push(nameText); + if (resolver.getNodeCheckFlags(name.parent) & NodeCheckFlags.NeedsLoopOutParameter) { + const reassignedVariable = { originalName: name, outParamName: makeUniqueName(`out_${nameText}`) }; + (loopOutParameters || (loopOutParameters = [])).push(reassignedVariable); + } } else { for (const element of (name).elements) { - collectNames(element.name); + processVariableDeclaration(element.name); } } } @@ -3124,6 +3201,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } } + function copyLoopOutParameters(state: ConvertedLoopState, copyDirection: CopyDirection, emitAsStatements: boolean) { + if (state.loopOutParameters) { + for (const outParam of state.loopOutParameters) { + if (copyDirection === CopyDirection.ToOriginal) { + emitIdentifier(outParam.originalName); + write(` = ${outParam.outParamName}`); + } + else { + write(`${outParam.outParamName} = `); + emitIdentifier(outParam.originalName); + } + if (emitAsStatements) { + write(";"); + writeLine(); + } + else { + write(", "); + } + } + } + } + function emitConvertedLoopCall(loop: ConvertedLoop, emitAsBlock: boolean): void { if (emitAsBlock) { write(" {"); @@ -3138,12 +3237,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge !loop.state.labeledNonLocalBreaks && !loop.state.labeledNonLocalContinues; + copyLoopOutParameters(loop.state, CopyDirection.ToOutParameter, /*emitAsStatements*/ true); + writeLine(); + const loopResult = makeUniqueName("state"); if (!isSimpleLoop) { write(`var ${loopResult} = `); } write(`${loop.functionName}(${loop.paramList});`); + writeLine(); + + copyLoopOutParameters(loop.state, CopyDirection.ToOriginal, /*emitAsStatements*/ true); if (!isSimpleLoop) { // for non simple loops we need to store result returned from converted loop function and use it to do dispatching @@ -3463,14 +3568,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { + write ("return "); + // explicit exit from loop -> copy out parameters + copyLoopOutParameters(convertedLoopState, CopyDirection.ToOutParameter, /*emitAsStatements*/ false); if (!node.label) { if (node.kind === SyntaxKind.BreakStatement) { convertedLoopState.nonLocalJumps |= Jump.Break; - write(`return "break";`); + write(`"break";`); } else { convertedLoopState.nonLocalJumps |= Jump.Continue; - write(`return "continue";`); + write(`"continue";`); } } else { @@ -3483,7 +3591,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge labelMarker = `continue-${node.label.text}`; setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); } - write(`return "${labelMarker}";`); + write(`"${labelMarker}";`); } return; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5545fbd162e..b5040ed5eb9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2044,6 +2044,7 @@ namespace ts { HasSeenSuperCall = 0x00080000, // Set during the binding when encounter 'super' ClassWithBodyScopedClassBinding = 0x00100000, // Decorated class that contains a binding to itself inside of the class body. BodyScopedClassBinding = 0x00200000, // Binding to a decorated class inside of the class's body. + NeedsLoopOutParameter = 0x00400000, // Block scoped binding whose value should be explicitly copied outside of the converted loop } /* @internal */ diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js new file mode 100644 index 00000000000..84e013c3b02 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js @@ -0,0 +1,23 @@ +//// [blockScopedBindingsReassignedInLoop1.ts] +declare function use(n: number): void; +(function () { + 'use strict' + for (let i = 0; i < 9; ++i) { + (() => use(++i))(); + } +})(); + +//// [blockScopedBindingsReassignedInLoop1.js] +(function () { + 'use strict'; + var _loop_1 = function(i) { + (function () { return use(++i); })(); + out_i_1 = i; + }; + var out_i_1; + for (var i = 0; i < 9; ++i) { + out_i_1 = i; + _loop_1(i); + i = out_i_1; + } +})(); diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.symbols new file mode 100644 index 00000000000..8024124b04e --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts === +declare function use(n: number): void; +>use : Symbol(use, Decl(blockScopedBindingsReassignedInLoop1.ts, 0, 0)) +>n : Symbol(n, Decl(blockScopedBindingsReassignedInLoop1.ts, 0, 21)) + +(function () { + 'use strict' + for (let i = 0; i < 9; ++i) { +>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10)) +>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10)) +>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10)) + + (() => use(++i))(); +>use : Symbol(use, Decl(blockScopedBindingsReassignedInLoop1.ts, 0, 0)) +>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10)) + } +})(); diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types new file mode 100644 index 00000000000..7ced53508e6 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts === +declare function use(n: number): void; +>use : (n: number) => void +>n : number + +(function () { +>(function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }})() : void +>(function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }}) : () => void +>function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }} : () => void + + 'use strict' +>'use strict' : string + + for (let i = 0; i < 9; ++i) { +>i : number +>0 : number +>i < 9 : boolean +>i : number +>9 : number +>++i : number +>i : number + + (() => use(++i))(); +>(() => use(++i))() : void +>(() => use(++i)) : () => void +>() => use(++i) : () => void +>use(++i) : void +>use : (n: number) => void +>++i : number +>i : number + } +})(); diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js new file mode 100644 index 00000000000..82719448e24 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js @@ -0,0 +1,128 @@ +//// [blockScopedBindingsReassignedInLoop2.ts] +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break; + } + else { + y = 5; + } +} + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue; + } + else { + y = 5; + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break loop; + } + else { + y = 5; + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue loop; + } + else { + y = 5; + } +} + +//// [blockScopedBindingsReassignedInLoop2.js] +var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_1 = x, out_y_1 = y, "break"; + } + else { + y = 5; + } + out_x_1 = x; + out_y_1 = y; +}; +var out_x_1, out_y_1; +for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_1 = x; + out_y_1 = y; + var state_1 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (state_1 === "break") break; +} +var _loop_2 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_2 = x, out_y_2 = y, "continue"; + } + else { + y = 5; + } + out_x_2 = x; + out_y_2 = y; +}; +var out_x_2, out_y_2; +for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_2 = x; + out_y_2 = y; + var state_2 = _loop_2(x, y); + x = out_x_2; + y = out_y_2; + if (state_2 === "continue") continue; +} +var _loop_3 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_3 = x, out_y_3 = y, "break-loop"; + } + else { + y = 5; + } + out_x_3 = x; + out_y_3 = y; +}; +var out_x_3, out_y_3; +loop: for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_3 = x; + out_y_3 = y; + var state_3 = _loop_3(x, y); + x = out_x_3; + y = out_y_3; + switch(state_3) { + case "break-loop": break loop; + } +} +var _loop_4 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_4 = x, out_y_4 = y, "continue-loop"; + } + else { + y = 5; + } + out_x_4 = x; + out_y_4 = y; +}; +var out_x_4, out_y_4; +loop: for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_4 = x; + out_y_4 = y; + var state_4 = _loop_4(x, y); + x = out_x_4; + y = out_y_4; + switch(state_4) { + case "continue-loop": continue loop; + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.symbols new file mode 100644 index 00000000000..fcaea39564f --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.symbols @@ -0,0 +1,98 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts === +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 1, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) + + break; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) + } +} + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 11, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) + + continue; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 22, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) + + break loop; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 33, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) + + continue loop; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types new file mode 100644 index 00000000000..244160dcc6b --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types @@ -0,0 +1,160 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts === +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + break; + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + continue; + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +loop: +>loop : any + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + break loop; +>loop : any + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +loop: +>loop : any + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + continue loop; +>loop : any + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js new file mode 100644 index 00000000000..8780afbdf54 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js @@ -0,0 +1,259 @@ +//// [blockScopedBindingsReassignedInLoop3.ts] + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break; + } + else { + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + break; + } + else { + y++; + } + } + + y = 5; + } +} + + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue; + } + else { + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + continue; + } + else { + y++; + } + } + + y = 5; + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + break loop1; + } + else { + y++; + break loop2 + } + } + + y = 5; + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + continue loop1; + } + else { + y++; + continue loop2 + } + } + + y = 5; + } +} + + +//// [blockScopedBindingsReassignedInLoop3.js] +var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_1 = x, out_y_1 = y, "break"; + } + else { + var _loop_2 = function(a_1) { + var f = function () { return a_1; }; + if (a_1) { + a_1 = x; + return out_a_1_1 = a_1, "break"; + } + else { + y++; + } + out_a_1_1 = a_1; + }; + var out_a_1_1; + for (var a_1 = 1; a_1 < 5; --a_1) { + out_a_1_1 = a_1; + var state_1 = _loop_2(a_1); + a_1 = out_a_1_1; + if (state_1 === "break") break; + } + y = 5; + } + out_x_1 = x; + out_y_1 = y; +}; +var out_x_1, out_y_1; +for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_1 = x; + out_y_1 = y; + var state_2 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (state_2 === "break") break; +} +var _loop_3 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_2 = x, out_y_2 = y, "continue"; + } + else { + var _loop_4 = function(a_2) { + var f = function () { return a_2; }; + if (a_2) { + a_2 = x; + return out_a_2_1 = a_2, "continue"; + } + else { + y++; + } + out_a_2_1 = a_2; + }; + var out_a_2_1; + for (var a_2 = 1; a_2 < 5; --a_2) { + out_a_2_1 = a_2; + var state_3 = _loop_4(a_2); + a_2 = out_a_2_1; + if (state_3 === "continue") continue; + } + y = 5; + } + out_x_2 = x; + out_y_2 = y; +}; +var out_x_2, out_y_2; +for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_2 = x; + out_y_2 = y; + var state_4 = _loop_3(x, y); + x = out_x_2; + y = out_y_2; + if (state_4 === "continue") continue; +} +var _loop_5 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_3 = x, out_y_3 = y, "break-loop2"; + } + else { + var _loop_6 = function(a_3) { + var f = function () { return a_3; }; + if (a_3) { + a_3 = x; + return out_a_3_1 = a_3, "break-loop1"; + } + else { + y++; + return out_a_3_1 = a_3, "break-loop2"; + } + out_a_3_1 = a_3; + }; + var out_a_3_1; + loop1: for (var a_3 = 1; a_3 < 5; --a_3) { + out_a_3_1 = a_3; + var state_5 = _loop_6(a_3); + a_3 = out_a_3_1; + switch(state_5) { + case "break-loop1": break loop1; + case "break-loop2": return state_5; + } + } + y = 5; + } + out_x_3 = x; + out_y_3 = y; +}; +var out_x_3, out_y_3; +loop2: for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_3 = x; + out_y_3 = y; + var state_6 = _loop_5(x, y); + x = out_x_3; + y = out_y_3; + switch(state_6) { + case "break-loop2": break loop2; + } +} +var _loop_7 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_4 = x, out_y_4 = y, "continue-loop2"; + } + else { + var _loop_8 = function(a_4) { + var f = function () { return a_4; }; + if (a_4) { + a_4 = x; + return out_a_4_1 = a_4, "continue-loop1"; + } + else { + y++; + return out_a_4_1 = a_4, "continue-loop2"; + } + out_a_4_1 = a_4; + }; + var out_a_4_1; + loop1: for (var a_4 = 1; a_4 < 5; --a_4) { + out_a_4_1 = a_4; + var state_7 = _loop_8(a_4); + a_4 = out_a_4_1; + switch(state_7) { + case "continue-loop1": continue loop1; + case "continue-loop2": return state_7; + } + } + y = 5; + } + out_x_4 = x; + out_y_4 = y; +}; +var out_x_4, out_y_4; +loop2: for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_4 = x; + out_y_4 = y; + var state_8 = _loop_7(x, y); + x = out_x_4; + y = out_y_4; + switch(state_8) { + case "continue-loop2": continue loop2; + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.symbols new file mode 100644 index 00000000000..f78cd684c3a --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.symbols @@ -0,0 +1,203 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts === + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 2, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) + + break; + } + else { + for (let a = 1; a < 5; --a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) + + let f = () => a; +>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 8, 15)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) + + if (a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) + + a = x; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) + + break; + } + else { + y++; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) + } + } + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) + } +} + + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 24, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) + + continue; + } + else { + for (let a = 1; a < 5; --a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) + + let f = () => a; +>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 30, 15)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) + + if (a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) + + a = x; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) + + continue; + } + else { + y++; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) + } + } + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 46, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) + + break loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) + + let f = () => a; +>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 53, 15)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) + + if (a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) + + a = x; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) + + break loop1; + } + else { + y++; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) + + break loop2 + } + } + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 70, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) + + continue loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) + + let f = () => a; +>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 77, 15)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) + + if (a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) + + a = x; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) + + continue loop1; + } + else { + y++; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) + + continue loop2 + } + } + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) + } +} + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types new file mode 100644 index 00000000000..0753391d5c2 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types @@ -0,0 +1,301 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts === + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + break; + } + else { + for (let a = 1; a < 5; --a) { +>a : number +>1 : number +>a < 5 : boolean +>a : number +>5 : number +>--a : number +>a : number + + let f = () => a; +>f : () => number +>() => a : () => number +>a : number + + if (a) { +>a : number + + a = x; +>a = x : number +>a : number +>x : number + + break; + } + else { + y++; +>y++ : number +>y : number + } + } + + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + continue; + } + else { + for (let a = 1; a < 5; --a) { +>a : number +>1 : number +>a < 5 : boolean +>a : number +>5 : number +>--a : number +>a : number + + let f = () => a; +>f : () => number +>() => a : () => number +>a : number + + if (a) { +>a : number + + a = x; +>a = x : number +>a : number +>x : number + + continue; + } + else { + y++; +>y++ : number +>y : number + } + } + + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +loop2: +>loop2 : any + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + break loop2; +>loop2 : any + } + else { + loop1: +>loop1 : any + + for (let a = 1; a < 5; --a) { +>a : number +>1 : number +>a < 5 : boolean +>a : number +>5 : number +>--a : number +>a : number + + let f = () => a; +>f : () => number +>() => a : () => number +>a : number + + if (a) { +>a : number + + a = x; +>a = x : number +>a : number +>x : number + + break loop1; +>loop1 : any + } + else { + y++; +>y++ : number +>y : number + + break loop2 +>loop2 : any + } + } + + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +loop2: +>loop2 : any + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + continue loop2; +>loop2 : any + } + else { + loop1: +>loop1 : any + + for (let a = 1; a < 5; --a) { +>a : number +>1 : number +>a < 5 : boolean +>a : number +>5 : number +>--a : number +>a : number + + let f = () => a; +>f : () => number +>() => a : () => number +>a : number + + if (a) { +>a : number + + a = x; +>a = x : number +>a : number +>x : number + + continue loop1; +>loop1 : any + } + else { + y++; +>y++ : number +>y : number + + continue loop2 +>loop2 : any + } + } + + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js new file mode 100644 index 00000000000..e28c890932a --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js @@ -0,0 +1,36 @@ +//// [blockScopedBindingsReassignedInLoop4.ts] +function f1() { + for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + return 1; + } + else { + y = 5; + } + } +} + +//// [blockScopedBindingsReassignedInLoop4.js] +function f1() { + var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return { value: 1 }; + } + else { + y = 5; + } + out_x_1 = x; + out_y_1 = y; + }; + var out_x_1, out_y_1; + for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_1 = x; + out_y_1 = y; + var state_1 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (typeof state_1 === "object") return state_1.value; + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.symbols new file mode 100644 index 00000000000..90c63914b9f --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.symbols @@ -0,0 +1,28 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts === +function f1() { +>f1 : Symbol(f1, Decl(blockScopedBindingsReassignedInLoop4.ts, 0, 0)) + + for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop4.ts, 2, 11)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) + + return 1; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) + } + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types new file mode 100644 index 00000000000..006f536ccca --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts === +function f1() { +>f1 : () => number + + for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + return 1; +>1 : number + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js new file mode 100644 index 00000000000..198303390c9 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js @@ -0,0 +1,29 @@ +//// [blockScopedBindingsReassignedInLoop5.ts] +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else + y = 5; +} + + +//// [blockScopedBindingsReassignedInLoop5.js] +var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) + return out_x_1 = x, out_y_1 = y, "break"; + else + y = 5; + out_x_1 = x; + out_y_1 = y; +}; +var out_x_1, out_y_1; +for (var x = 1, y = 2; x < y; ++x, --y) { + out_x_1 = x; + out_y_1 = y; + var state_1 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (state_1 === "break") break; +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.symbols new file mode 100644 index 00000000000..0edc6abe34d --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts === +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop5.ts, 1, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) + + if (x == 1) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) + + break; + else + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) +} + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types new file mode 100644 index 00000000000..530978dc722 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts === +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) +>x == 1 : boolean +>x : number +>1 : number + + break; + else + y = 5; +>y = 5 : number +>y : number +>5 : number +} + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js new file mode 100644 index 00000000000..f958b29c583 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js @@ -0,0 +1,78 @@ +//// [blockScopedBindingsReassignedInLoop6.ts] +function f1() { + for (let [x, y] = [1, 2]; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else if (y == 2) + y = 5; + else + return; + } +} + +function f2() { + for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else if (y == 2) + y = 5; + else + return; + } +} + + + + + + + +//// [blockScopedBindingsReassignedInLoop6.js] +function f1() { + var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) + return out_x_1 = x, out_y_1 = y, "break"; + else if (y == 2) + y = 5; + else + return { value: void 0 }; + out_x_1 = x; + out_y_1 = y; + }; + var out_x_1, out_y_1; + for (var _a = [1, 2], x = _a[0], y = _a[1]; x < y; ++x, --y) { + out_x_1 = x; + out_y_1 = y; + var state_1 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (typeof state_1 === "object") return state_1.value; + if (state_1 === "break") break; + } +} +function f2() { + var _loop_2 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) + return out_x_2 = x, out_y_2 = y, "break"; + else if (y == 2) + y = 5; + else + return { value: void 0 }; + out_x_2 = x; + out_y_2 = y; + }; + var out_x_2, out_y_2; + for (var _a = [{ a: 1, b: { c: 2 } }][0], x = _a.a, y = _a.b.c; x < y; ++x, --y) { + out_x_2 = x; + out_y_2 = y; + var state_2 = _loop_2(x, y); + x = out_x_2; + y = out_y_2; + if (typeof state_2 === "object") return state_2.value; + if (state_2 === "break") break; + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.symbols new file mode 100644 index 00000000000..8dda6eedd47 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.symbols @@ -0,0 +1,74 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts === +function f1() { +>f1 : Symbol(f1, Decl(blockScopedBindingsReassignedInLoop6.ts, 0, 0)) + + for (let [x, y] = [1, 2]; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 2, 11)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) + + if (x == 1) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) + + break; + else if (y == 2) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) + + else + return; + } +} + +function f2() { +>f2 : Symbol(f2, Decl(blockScopedBindingsReassignedInLoop6.ts, 10, 1)) + + for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 37)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) +>b : Symbol(b, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 42)) +>c : Symbol(c, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 47)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 37)) +>b : Symbol(b, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 42)) +>c : Symbol(c, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 47)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 14, 11)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) + + if (x == 1) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) + + break; + else if (y == 2) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) + + else + return; + } +} + + + + + + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types new file mode 100644 index 00000000000..673c0788a03 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types @@ -0,0 +1,110 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts === +function f1() { +>f1 : () => void + + for (let [x, y] = [1, 2]; x < y; ++x, --y) { +>x : number +>y : number +>[1, 2] : [number, number] +>1 : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) +>x == 1 : boolean +>x : number +>1 : number + + break; + else if (y == 2) +>y == 2 : boolean +>y : number +>2 : number + + y = 5; +>y = 5 : number +>y : number +>5 : number + + else + return; + } +} + +function f2() { +>f2 : () => void + + for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) { +>a : any +>x : number +>b : any +>c : any +>y : number +>[{a: 1, b: {c: 2}}] : [{ a: number; b: { c: number; }; }] +>{a: 1, b: {c: 2}} : { a: number; b: { c: number; }; } +>a : number +>1 : number +>b : { c: number; } +>{c: 2} : { c: number; } +>c : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) +>x == 1 : boolean +>x : number +>1 : number + + break; + else if (y == 2) +>y == 2 : boolean +>y : number +>2 : number + + y = 5; +>y = 5 : number +>y : number +>5 : number + + else + return; + } +} + + + + + + diff --git a/tests/baselines/reference/nestedBlockScopedBindings3.js b/tests/baselines/reference/nestedBlockScopedBindings3.js index 97fba2da301..4570e85d510 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings3.js +++ b/tests/baselines/reference/nestedBlockScopedBindings3.js @@ -123,9 +123,13 @@ function a4() { var _loop_5 = function(x) { x = x + 1; (function () { return x; }); + out_x_1 = x; }; + var out_x_1; for (var x = void 0; x < 1;) { + out_x_1 = x; _loop_5(x); + x = out_x_1; } switch (1) { case 1: @@ -137,9 +141,13 @@ function a5() { var _loop_6 = function(x) { x = x + 1; (function () { return x; }); + out_x_2 = x; }; + var out_x_2; for (var x = void 0; x < 1;) { + out_x_2 = x; _loop_6(x); + x = out_x_2; } switch (1) { case 1: diff --git a/tests/baselines/reference/nestedBlockScopedBindings4.js b/tests/baselines/reference/nestedBlockScopedBindings4.js index 51cddcf676d..832feb588bc 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings4.js +++ b/tests/baselines/reference/nestedBlockScopedBindings4.js @@ -53,9 +53,13 @@ function a1() { var _loop_1 = function(x) { x = x + 1; (function () { return x; }); + out_x_1 = x; }; + var out_x_1; for (var x = void 0; x < 1;) { + out_x_1 = x; _loop_1(x); + x = out_x_1; } for (var x = void 0;;) { x = x + 2; @@ -68,24 +72,36 @@ function a2() { var _loop_2 = function(x) { x = x + 2; (function () { return x; }); + out_x_2 = x; }; + var out_x_2; for (var x = void 0;;) { + out_x_2 = x; _loop_2(x); + x = out_x_2; } } function a3() { var _loop_3 = function(x) { x = x + 1; (function () { return x; }); + out_x_3 = x; }; + var out_x_3; for (var x = void 0; x < 1;) { + out_x_3 = x; _loop_3(x); + x = out_x_3; } var _loop_4 = function(x) { x = x + 2; (function () { return x; }); + out_x_4 = x; }; + var out_x_4; for (var x = void 0;;) { + out_x_4 = x; _loop_4(x); + x = out_x_4; } } diff --git a/tests/baselines/reference/nestedBlockScopedBindings5.js b/tests/baselines/reference/nestedBlockScopedBindings5.js index c80c72c0ed6..af91e9999a6 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings5.js +++ b/tests/baselines/reference/nestedBlockScopedBindings5.js @@ -108,9 +108,13 @@ function a2() { var _loop_2 = function(x) { x = x + 2; (function () { return x; }); + out_x_1 = x; }; + var out_x_1; for (var x = void 0;;) { + out_x_1 = x; _loop_2(x); + x = out_x_1; } } function a3() { @@ -124,9 +128,13 @@ function a3() { var _loop_4 = function(x) { x = x + 2; (function () { return x; }); + out_x_2 = x; }; + var out_x_2; for (var x = void 0; false;) { + out_x_2 = x; _loop_4(x); + x = out_x_2; } switch (1) { case 1: @@ -157,9 +165,13 @@ function a5() { var _loop_5 = function(x) { x = x + 2; (function () { return x; }); + out_x_3 = x; }; + var out_x_3; for (var x = void 0; false;) { + out_x_3 = x; _loop_5(x); + x = out_x_3; } switch (1) { case 1: diff --git a/tests/baselines/reference/nestedBlockScopedBindings6.js b/tests/baselines/reference/nestedBlockScopedBindings6.js index 78207b98fcd..43f61a23bbf 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings6.js +++ b/tests/baselines/reference/nestedBlockScopedBindings6.js @@ -119,9 +119,13 @@ function a2() { var _loop_2 = function(x) { x = x + 2; (function () { return x; }); + out_x_1 = x; }; + var out_x_1; for (var x = void 0;;) { + out_x_1 = x; _loop_2(x); + x = out_x_1; } } function a3() { @@ -136,9 +140,13 @@ function a3() { var _loop_4 = function(x) { x = x + 2; (function () { return x; }); + out_x_2 = x; }; + var out_x_2; for (var x = void 0;;) { + out_x_2 = x; _loop_4(x); + x = out_x_2; } } function a4() { diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts new file mode 100644 index 00000000000..e052702bce2 --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts @@ -0,0 +1,7 @@ +declare function use(n: number): void; +(function () { + 'use strict' + for (let i = 0; i < 9; ++i) { + (() => use(++i))(); + } +})(); \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts new file mode 100644 index 00000000000..84d9f8d214b --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts @@ -0,0 +1,41 @@ +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break; + } + else { + y = 5; + } +} + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue; + } + else { + y = 5; + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break loop; + } + else { + y = 5; + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue loop; + } + else { + y = 5; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts new file mode 100644 index 00000000000..a68c708193a --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts @@ -0,0 +1,91 @@ + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break; + } + else { + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + break; + } + else { + y++; + } + } + + y = 5; + } +} + + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue; + } + else { + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + continue; + } + else { + y++; + } + } + + y = 5; + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + break loop1; + } + else { + y++; + break loop2 + } + } + + y = 5; + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + continue loop1; + } + else { + y++; + continue loop2 + } + } + + y = 5; + } +} diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts new file mode 100644 index 00000000000..82f4bcc5dd0 --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts @@ -0,0 +1,11 @@ +function f1() { + for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + return 1; + } + else { + y = 5; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts new file mode 100644 index 00000000000..c6c577ea9fb --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts @@ -0,0 +1,7 @@ +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else + y = 5; +} diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts new file mode 100644 index 00000000000..e735bb61ac8 --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts @@ -0,0 +1,28 @@ +function f1() { + for (let [x, y] = [1, 2]; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else if (y == 2) + y = 5; + else + return; + } +} + +function f2() { + for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else if (y == 2) + y = 5; + else + return; + } +} + + + + + From e347c3711cc4b85eda34f1aba844e1a6576ff40c Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 4 Feb 2016 10:14:13 -0800 Subject: [PATCH 028/102] Add more complex test scenarios --- tests/cases/fourslash/jsDocGenerics1.ts | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/cases/fourslash/jsDocGenerics1.ts b/tests/cases/fourslash/jsDocGenerics1.ts index 3b5742af8b1..61358e3f490 100644 --- a/tests/cases/fourslash/jsDocGenerics1.ts +++ b/tests/cases/fourslash/jsDocGenerics1.ts @@ -1,10 +1,34 @@ /// // @allowNonTsExtensions: true +// @Filename: ref.d.ts +//// namespace Thing { +//// export interface Thung { +//// a: number; +//// ] +//// ] + + // @Filename: Foo.js +//// //// /** @type {Array} */ //// var v; -//// v[0]./**/ +//// v[0]./*1*/ +//// +//// /** @type {{x: Array>}} */ +//// var w; +//// w.x[0][0]./*2*/ +//// +//// /** @type {Array} */ +//// var x; +//// x[0].a./*3*/ -goTo.marker(); + +goTo.marker('1'); +verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); + +goTo.marker('2'); +verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); + +goTo.marker('3'); verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); From 1611f5648146ff5f90bf0e11556e1fa5fdbe9398 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 4 Feb 2016 12:44:03 -0800 Subject: [PATCH 029/102] Rename flag --- src/compiler/commandLineParser.ts | 2 +- src/compiler/emitter.ts | 8 ++++---- src/compiler/types.ts | 2 +- .../reference/emitModulesInLooseMode_amd.symbols | 5 ----- .../baselines/reference/emitModulesInLooseMode_amd.types | 6 ------ .../reference/emitModulesInLooseMode_commonjs.js | 6 ------ .../reference/emitModulesInLooseMode_commonjs.symbols | 5 ----- .../reference/emitModulesInLooseMode_commonjs.types | 6 ------ tests/baselines/reference/emitModulesInLooseMode_es6.js | 6 ------ .../reference/emitModulesInLooseMode_es6.symbols | 5 ----- .../baselines/reference/emitModulesInLooseMode_es6.types | 6 ------ .../reference/emitModulesInLooseMode_system.symbols | 5 ----- .../reference/emitModulesInLooseMode_system.types | 6 ------ .../reference/emitModulesInLooseMode_umd.symbols | 5 ----- .../baselines/reference/emitModulesInLooseMode_umd.types | 6 ------ ...ulesInLooseMode_amd.js => emitNonStrictModules_amd.js} | 4 ++-- .../baselines/reference/emitNonStrictModules_amd.symbols | 5 +++++ tests/baselines/reference/emitNonStrictModules_amd.types | 6 ++++++ .../baselines/reference/emitNonStrictModules_commonjs.js | 6 ++++++ .../reference/emitNonStrictModules_commonjs.symbols | 5 +++++ .../reference/emitNonStrictModules_commonjs.types | 6 ++++++ tests/baselines/reference/emitNonStrictModules_es6.js | 6 ++++++ .../baselines/reference/emitNonStrictModules_es6.symbols | 5 +++++ tests/baselines/reference/emitNonStrictModules_es6.types | 6 ++++++ ...LooseMode_system.js => emitNonStrictModules_system.js} | 4 ++-- .../reference/emitNonStrictModules_system.symbols | 5 +++++ .../baselines/reference/emitNonStrictModules_system.types | 6 ++++++ ...ulesInLooseMode_umd.js => emitNonStrictModules_umd.js} | 4 ++-- .../baselines/reference/emitNonStrictModules_umd.symbols | 5 +++++ tests/baselines/reference/emitNonStrictModules_umd.types | 6 ++++++ tests/cases/compiler/emitModulesInLooseMode_amd.ts | 4 ---- tests/cases/compiler/emitModulesInLooseMode_commonjs.ts | 4 ---- tests/cases/compiler/emitModulesInLooseMode_es6.ts | 5 ----- tests/cases/compiler/emitModulesInLooseMode_system.ts | 4 ---- tests/cases/compiler/emitModulesInLooseMode_umd.ts | 4 ---- tests/cases/compiler/emitNonStrictModules_amd.ts | 4 ++++ tests/cases/compiler/emitNonStrictModules_commonjs.ts | 4 ++++ tests/cases/compiler/emitNonStrictModules_es6.ts | 5 +++++ tests/cases/compiler/emitNonStrictModules_system.ts | 4 ++++ tests/cases/compiler/emitNonStrictModules_umd.ts | 4 ++++ 40 files changed, 100 insertions(+), 100 deletions(-) delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_amd.symbols delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_amd.types delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_commonjs.js delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_commonjs.symbols delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_commonjs.types delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_es6.js delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_es6.symbols delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_es6.types delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_system.symbols delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_system.types delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_umd.symbols delete mode 100644 tests/baselines/reference/emitModulesInLooseMode_umd.types rename tests/baselines/reference/{emitModulesInLooseMode_amd.js => emitNonStrictModules_amd.js} (56%) create mode 100644 tests/baselines/reference/emitNonStrictModules_amd.symbols create mode 100644 tests/baselines/reference/emitNonStrictModules_amd.types create mode 100644 tests/baselines/reference/emitNonStrictModules_commonjs.js create mode 100644 tests/baselines/reference/emitNonStrictModules_commonjs.symbols create mode 100644 tests/baselines/reference/emitNonStrictModules_commonjs.types create mode 100644 tests/baselines/reference/emitNonStrictModules_es6.js create mode 100644 tests/baselines/reference/emitNonStrictModules_es6.symbols create mode 100644 tests/baselines/reference/emitNonStrictModules_es6.types rename tests/baselines/reference/{emitModulesInLooseMode_system.js => emitNonStrictModules_system.js} (72%) create mode 100644 tests/baselines/reference/emitNonStrictModules_system.symbols create mode 100644 tests/baselines/reference/emitNonStrictModules_system.types rename tests/baselines/reference/{emitModulesInLooseMode_umd.js => emitNonStrictModules_umd.js} (81%) create mode 100644 tests/baselines/reference/emitNonStrictModules_umd.symbols create mode 100644 tests/baselines/reference/emitNonStrictModules_umd.types delete mode 100644 tests/cases/compiler/emitModulesInLooseMode_amd.ts delete mode 100644 tests/cases/compiler/emitModulesInLooseMode_commonjs.ts delete mode 100644 tests/cases/compiler/emitModulesInLooseMode_es6.ts delete mode 100644 tests/cases/compiler/emitModulesInLooseMode_system.ts delete mode 100644 tests/cases/compiler/emitModulesInLooseMode_umd.ts create mode 100644 tests/cases/compiler/emitNonStrictModules_amd.ts create mode 100644 tests/cases/compiler/emitNonStrictModules_commonjs.ts create mode 100644 tests/cases/compiler/emitNonStrictModules_es6.ts create mode 100644 tests/cases/compiler/emitNonStrictModules_system.ts create mode 100644 tests/cases/compiler/emitNonStrictModules_umd.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 7d635c2aaf5..957b38c67de 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -322,7 +322,7 @@ namespace ts { description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { - name: "emitModulesInLooseMode", + name: "emitNonStrictModules", type: "boolean", description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 92cb3334f63..15edb022b11 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7179,7 +7179,7 @@ const _super = (function (geti, seti) { write(`], function(${exportFunctionForFile}, ${contextObjectForFile}) {`); writeLine(); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.emitModulesInLooseMode); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.emitNonStrictModules); writeLine(); write(`var __moduleName = ${contextObjectForFile} && ${contextObjectForFile}.id;`); writeLine(); @@ -7285,7 +7285,7 @@ const _super = (function (geti, seti) { writeModuleName(node, emitRelativePathAsModuleName); emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/!compilerOptions.emitModulesInLooseMode); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/!compilerOptions.emitNonStrictModules); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -7297,7 +7297,7 @@ const _super = (function (geti, seti) { } function emitCommonJSModule(node: SourceFile) { - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.emitModulesInLooseMode); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.emitNonStrictModules); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -7326,7 +7326,7 @@ const _super = (function (geti, seti) { })(`); emitAMDFactoryHeader(dependencyNames); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.emitModulesInLooseMode); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.emitNonStrictModules); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 97cf2fff3b5..90a6a9a6752 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2422,7 +2422,7 @@ namespace ts { traceModuleResolution?: boolean; allowSyntheticDefaultImports?: boolean; allowJs?: boolean; - emitModulesInLooseMode?: boolean; + emitNonStrictModules?: boolean; /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. diff --git a/tests/baselines/reference/emitModulesInLooseMode_amd.symbols b/tests/baselines/reference/emitModulesInLooseMode_amd.symbols deleted file mode 100644 index d76fea8b7b8..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_amd.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_amd.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitModulesInLooseMode_amd.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitModulesInLooseMode_amd.types b/tests/baselines/reference/emitModulesInLooseMode_amd.types deleted file mode 100644 index 1c070cc95fa..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_amd.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_amd.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitModulesInLooseMode_commonjs.js b/tests/baselines/reference/emitModulesInLooseMode_commonjs.js deleted file mode 100644 index be24cdf6b91..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_commonjs.js +++ /dev/null @@ -1,6 +0,0 @@ -//// [emitModulesInLooseMode_commonjs.ts] - -export var x = 0; - -//// [emitModulesInLooseMode_commonjs.js] -exports.x = 0; diff --git a/tests/baselines/reference/emitModulesInLooseMode_commonjs.symbols b/tests/baselines/reference/emitModulesInLooseMode_commonjs.symbols deleted file mode 100644 index 225286c74de..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_commonjs.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_commonjs.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitModulesInLooseMode_commonjs.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitModulesInLooseMode_commonjs.types b/tests/baselines/reference/emitModulesInLooseMode_commonjs.types deleted file mode 100644 index b37bb9667ab..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_commonjs.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_commonjs.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitModulesInLooseMode_es6.js b/tests/baselines/reference/emitModulesInLooseMode_es6.js deleted file mode 100644 index 95cc14ff609..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_es6.js +++ /dev/null @@ -1,6 +0,0 @@ -//// [emitModulesInLooseMode_es6.ts] - -export var x = 0; - -//// [emitModulesInLooseMode_es6.js] -export var x = 0; diff --git a/tests/baselines/reference/emitModulesInLooseMode_es6.symbols b/tests/baselines/reference/emitModulesInLooseMode_es6.symbols deleted file mode 100644 index 4f3c073f7ee..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_es6.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_es6.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitModulesInLooseMode_es6.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitModulesInLooseMode_es6.types b/tests/baselines/reference/emitModulesInLooseMode_es6.types deleted file mode 100644 index 84631ede00f..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_es6.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_es6.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitModulesInLooseMode_system.symbols b/tests/baselines/reference/emitModulesInLooseMode_system.symbols deleted file mode 100644 index 0682b2b648f..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_system.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_system.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitModulesInLooseMode_system.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitModulesInLooseMode_system.types b/tests/baselines/reference/emitModulesInLooseMode_system.types deleted file mode 100644 index 429908c1de4..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_system.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_system.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitModulesInLooseMode_umd.symbols b/tests/baselines/reference/emitModulesInLooseMode_umd.symbols deleted file mode 100644 index 86c9e9b200c..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_umd.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_umd.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitModulesInLooseMode_umd.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitModulesInLooseMode_umd.types b/tests/baselines/reference/emitModulesInLooseMode_umd.types deleted file mode 100644 index 98a32838eb6..00000000000 --- a/tests/baselines/reference/emitModulesInLooseMode_umd.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitModulesInLooseMode_umd.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitModulesInLooseMode_amd.js b/tests/baselines/reference/emitNonStrictModules_amd.js similarity index 56% rename from tests/baselines/reference/emitModulesInLooseMode_amd.js rename to tests/baselines/reference/emitNonStrictModules_amd.js index a93ca62de0e..f2a746280ac 100644 --- a/tests/baselines/reference/emitModulesInLooseMode_amd.js +++ b/tests/baselines/reference/emitNonStrictModules_amd.js @@ -1,8 +1,8 @@ -//// [emitModulesInLooseMode_amd.ts] +//// [emitNonStrictModules_amd.ts] export var x = 0; -//// [emitModulesInLooseMode_amd.js] +//// [emitNonStrictModules_amd.js] define(["require", "exports"], function (require, exports) { exports.x = 0; }); diff --git a/tests/baselines/reference/emitNonStrictModules_amd.symbols b/tests/baselines/reference/emitNonStrictModules_amd.symbols new file mode 100644 index 00000000000..1590ea05ad4 --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_amd.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitNonStrictModules_amd.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitNonStrictModules_amd.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitNonStrictModules_amd.types b/tests/baselines/reference/emitNonStrictModules_amd.types new file mode 100644 index 00000000000..650df648d8d --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_amd.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitNonStrictModules_amd.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitNonStrictModules_commonjs.js b/tests/baselines/reference/emitNonStrictModules_commonjs.js new file mode 100644 index 00000000000..7a2d0720015 --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_commonjs.js @@ -0,0 +1,6 @@ +//// [emitNonStrictModules_commonjs.ts] + +export var x = 0; + +//// [emitNonStrictModules_commonjs.js] +exports.x = 0; diff --git a/tests/baselines/reference/emitNonStrictModules_commonjs.symbols b/tests/baselines/reference/emitNonStrictModules_commonjs.symbols new file mode 100644 index 00000000000..36b487f34d1 --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_commonjs.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitNonStrictModules_commonjs.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitNonStrictModules_commonjs.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitNonStrictModules_commonjs.types b/tests/baselines/reference/emitNonStrictModules_commonjs.types new file mode 100644 index 00000000000..f8a24d53641 --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_commonjs.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitNonStrictModules_commonjs.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitNonStrictModules_es6.js b/tests/baselines/reference/emitNonStrictModules_es6.js new file mode 100644 index 00000000000..535afff7730 --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_es6.js @@ -0,0 +1,6 @@ +//// [emitNonStrictModules_es6.ts] + +export var x = 0; + +//// [emitNonStrictModules_es6.js] +export var x = 0; diff --git a/tests/baselines/reference/emitNonStrictModules_es6.symbols b/tests/baselines/reference/emitNonStrictModules_es6.symbols new file mode 100644 index 00000000000..884189014b0 --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitNonStrictModules_es6.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitNonStrictModules_es6.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitNonStrictModules_es6.types b/tests/baselines/reference/emitNonStrictModules_es6.types new file mode 100644 index 00000000000..f3208e247da --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitNonStrictModules_es6.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitModulesInLooseMode_system.js b/tests/baselines/reference/emitNonStrictModules_system.js similarity index 72% rename from tests/baselines/reference/emitModulesInLooseMode_system.js rename to tests/baselines/reference/emitNonStrictModules_system.js index 4cf401a554d..f1ad93f0009 100644 --- a/tests/baselines/reference/emitModulesInLooseMode_system.js +++ b/tests/baselines/reference/emitNonStrictModules_system.js @@ -1,8 +1,8 @@ -//// [emitModulesInLooseMode_system.ts] +//// [emitNonStrictModules_system.ts] export var x = 0; -//// [emitModulesInLooseMode_system.js] +//// [emitNonStrictModules_system.js] System.register([], function(exports_1, context_1) { var __moduleName = context_1 && context_1.id; var x; diff --git a/tests/baselines/reference/emitNonStrictModules_system.symbols b/tests/baselines/reference/emitNonStrictModules_system.symbols new file mode 100644 index 00000000000..b772eafe447 --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_system.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitNonStrictModules_system.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitNonStrictModules_system.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitNonStrictModules_system.types b/tests/baselines/reference/emitNonStrictModules_system.types new file mode 100644 index 00000000000..352381db379 --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_system.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitNonStrictModules_system.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitModulesInLooseMode_umd.js b/tests/baselines/reference/emitNonStrictModules_umd.js similarity index 81% rename from tests/baselines/reference/emitModulesInLooseMode_umd.js rename to tests/baselines/reference/emitNonStrictModules_umd.js index 327962d18f2..c1ee0c048c5 100644 --- a/tests/baselines/reference/emitModulesInLooseMode_umd.js +++ b/tests/baselines/reference/emitNonStrictModules_umd.js @@ -1,8 +1,8 @@ -//// [emitModulesInLooseMode_umd.ts] +//// [emitNonStrictModules_umd.ts] export var x = 0; -//// [emitModulesInLooseMode_umd.js] +//// [emitNonStrictModules_umd.js] (function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; diff --git a/tests/baselines/reference/emitNonStrictModules_umd.symbols b/tests/baselines/reference/emitNonStrictModules_umd.symbols new file mode 100644 index 00000000000..23af4139243 --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_umd.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/emitNonStrictModules_umd.ts === + +export var x = 0; +>x : Symbol(x, Decl(emitNonStrictModules_umd.ts, 1, 10)) + diff --git a/tests/baselines/reference/emitNonStrictModules_umd.types b/tests/baselines/reference/emitNonStrictModules_umd.types new file mode 100644 index 00000000000..83c55b1d4cd --- /dev/null +++ b/tests/baselines/reference/emitNonStrictModules_umd.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/emitNonStrictModules_umd.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/cases/compiler/emitModulesInLooseMode_amd.ts b/tests/cases/compiler/emitModulesInLooseMode_amd.ts deleted file mode 100644 index 7c3394bebae..00000000000 --- a/tests/cases/compiler/emitModulesInLooseMode_amd.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @module: amd -// @emitModulesInLooseMode: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitModulesInLooseMode_commonjs.ts b/tests/cases/compiler/emitModulesInLooseMode_commonjs.ts deleted file mode 100644 index 761f1f6ea9f..00000000000 --- a/tests/cases/compiler/emitModulesInLooseMode_commonjs.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @module: commonjs -// @emitModulesInLooseMode: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitModulesInLooseMode_es6.ts b/tests/cases/compiler/emitModulesInLooseMode_es6.ts deleted file mode 100644 index 22c4368629f..00000000000 --- a/tests/cases/compiler/emitModulesInLooseMode_es6.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @module: es6 -// @target: es6 -// @emitModulesInLooseMode: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitModulesInLooseMode_system.ts b/tests/cases/compiler/emitModulesInLooseMode_system.ts deleted file mode 100644 index 0face8fabca..00000000000 --- a/tests/cases/compiler/emitModulesInLooseMode_system.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @module: system -// @emitModulesInLooseMode: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitModulesInLooseMode_umd.ts b/tests/cases/compiler/emitModulesInLooseMode_umd.ts deleted file mode 100644 index a6a3559986f..00000000000 --- a/tests/cases/compiler/emitModulesInLooseMode_umd.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @module: umd -// @emitModulesInLooseMode: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitNonStrictModules_amd.ts b/tests/cases/compiler/emitNonStrictModules_amd.ts new file mode 100644 index 00000000000..217e23d91a3 --- /dev/null +++ b/tests/cases/compiler/emitNonStrictModules_amd.ts @@ -0,0 +1,4 @@ +// @module: amd +// @emitNonStrictModules: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitNonStrictModules_commonjs.ts b/tests/cases/compiler/emitNonStrictModules_commonjs.ts new file mode 100644 index 00000000000..3d29c30176f --- /dev/null +++ b/tests/cases/compiler/emitNonStrictModules_commonjs.ts @@ -0,0 +1,4 @@ +// @module: commonjs +// @emitNonStrictModules: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitNonStrictModules_es6.ts b/tests/cases/compiler/emitNonStrictModules_es6.ts new file mode 100644 index 00000000000..426c5aff533 --- /dev/null +++ b/tests/cases/compiler/emitNonStrictModules_es6.ts @@ -0,0 +1,5 @@ +// @module: es6 +// @target: es6 +// @emitNonStrictModules: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitNonStrictModules_system.ts b/tests/cases/compiler/emitNonStrictModules_system.ts new file mode 100644 index 00000000000..23801462b71 --- /dev/null +++ b/tests/cases/compiler/emitNonStrictModules_system.ts @@ -0,0 +1,4 @@ +// @module: system +// @emitNonStrictModules: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitNonStrictModules_umd.ts b/tests/cases/compiler/emitNonStrictModules_umd.ts new file mode 100644 index 00000000000..1166f512cf2 --- /dev/null +++ b/tests/cases/compiler/emitNonStrictModules_umd.ts @@ -0,0 +1,4 @@ +// @module: umd +// @emitNonStrictModules: true + +export var x = 0; \ No newline at end of file From d436d15304b7b1d45971e3071fe475371453c2ce Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 4 Feb 2016 12:44:31 -0800 Subject: [PATCH 030/102] addressed PR feedback --- src/compiler/emitter.ts | 3 --- .../blockScopedBindingsReassignedInLoop1.js | 1 - .../blockScopedBindingsReassignedInLoop2.js | 8 -------- .../blockScopedBindingsReassignedInLoop3.js | 12 ------------ .../blockScopedBindingsReassignedInLoop4.js | 2 -- .../blockScopedBindingsReassignedInLoop5.js | 2 -- .../blockScopedBindingsReassignedInLoop6.js | 4 ---- .../reference/nestedBlockScopedBindings3.js | 2 -- .../reference/nestedBlockScopedBindings4.js | 4 ---- .../reference/nestedBlockScopedBindings5.js | 3 --- .../reference/nestedBlockScopedBindings6.js | 2 -- 11 files changed, 43 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index be6a4dc36fc..aba0c883aaa 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3237,9 +3237,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge !loop.state.labeledNonLocalBreaks && !loop.state.labeledNonLocalContinues; - copyLoopOutParameters(loop.state, CopyDirection.ToOutParameter, /*emitAsStatements*/ true); - writeLine(); - const loopResult = makeUniqueName("state"); if (!isSimpleLoop) { write(`var ${loopResult} = `); diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js index 84e013c3b02..609d353fbc7 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js @@ -16,7 +16,6 @@ declare function use(n: number): void; }; var out_i_1; for (var i = 0; i < 9; ++i) { - out_i_1 = i; _loop_1(i); i = out_i_1; } diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js index 82719448e24..c48ecd96ffe 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js @@ -55,8 +55,6 @@ var _loop_1 = function(x, y) { }; var out_x_1, out_y_1; for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_1 = x; - out_y_1 = y; var state_1 = _loop_1(x, y); x = out_x_1; y = out_y_1; @@ -75,8 +73,6 @@ var _loop_2 = function(x, y) { }; var out_x_2, out_y_2; for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_2 = x; - out_y_2 = y; var state_2 = _loop_2(x, y); x = out_x_2; y = out_y_2; @@ -95,8 +91,6 @@ var _loop_3 = function(x, y) { }; var out_x_3, out_y_3; loop: for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_3 = x; - out_y_3 = y; var state_3 = _loop_3(x, y); x = out_x_3; y = out_y_3; @@ -117,8 +111,6 @@ var _loop_4 = function(x, y) { }; var out_x_4, out_y_4; loop: for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_4 = x; - out_y_4 = y; var state_4 = _loop_4(x, y); x = out_x_4; y = out_y_4; diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js index 8780afbdf54..10160202621 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js @@ -112,7 +112,6 @@ var _loop_1 = function(x, y) { }; var out_a_1_1; for (var a_1 = 1; a_1 < 5; --a_1) { - out_a_1_1 = a_1; var state_1 = _loop_2(a_1); a_1 = out_a_1_1; if (state_1 === "break") break; @@ -124,8 +123,6 @@ var _loop_1 = function(x, y) { }; var out_x_1, out_y_1; for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_1 = x; - out_y_1 = y; var state_2 = _loop_1(x, y); x = out_x_1; y = out_y_1; @@ -150,7 +147,6 @@ var _loop_3 = function(x, y) { }; var out_a_2_1; for (var a_2 = 1; a_2 < 5; --a_2) { - out_a_2_1 = a_2; var state_3 = _loop_4(a_2); a_2 = out_a_2_1; if (state_3 === "continue") continue; @@ -162,8 +158,6 @@ var _loop_3 = function(x, y) { }; var out_x_2, out_y_2; for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_2 = x; - out_y_2 = y; var state_4 = _loop_3(x, y); x = out_x_2; y = out_y_2; @@ -189,7 +183,6 @@ var _loop_5 = function(x, y) { }; var out_a_3_1; loop1: for (var a_3 = 1; a_3 < 5; --a_3) { - out_a_3_1 = a_3; var state_5 = _loop_6(a_3); a_3 = out_a_3_1; switch(state_5) { @@ -204,8 +197,6 @@ var _loop_5 = function(x, y) { }; var out_x_3, out_y_3; loop2: for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_3 = x; - out_y_3 = y; var state_6 = _loop_5(x, y); x = out_x_3; y = out_y_3; @@ -233,7 +224,6 @@ var _loop_7 = function(x, y) { }; var out_a_4_1; loop1: for (var a_4 = 1; a_4 < 5; --a_4) { - out_a_4_1 = a_4; var state_7 = _loop_8(a_4); a_4 = out_a_4_1; switch(state_7) { @@ -248,8 +238,6 @@ var _loop_7 = function(x, y) { }; var out_x_4, out_y_4; loop2: for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_4 = x; - out_y_4 = y; var state_8 = _loop_7(x, y); x = out_x_4; y = out_y_4; diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js index e28c890932a..8bff867dc95 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js @@ -26,8 +26,6 @@ function f1() { }; var out_x_1, out_y_1; for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_1 = x; - out_y_1 = y; var state_1 = _loop_1(x, y); x = out_x_1; y = out_y_1; diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js index 198303390c9..a891147317d 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js @@ -20,8 +20,6 @@ var _loop_1 = function(x, y) { }; var out_x_1, out_y_1; for (var x = 1, y = 2; x < y; ++x, --y) { - out_x_1 = x; - out_y_1 = y; var state_1 = _loop_1(x, y); x = out_x_1; y = out_y_1; diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js index f958b29c583..a2a074ed4df 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js @@ -44,8 +44,6 @@ function f1() { }; var out_x_1, out_y_1; for (var _a = [1, 2], x = _a[0], y = _a[1]; x < y; ++x, --y) { - out_x_1 = x; - out_y_1 = y; var state_1 = _loop_1(x, y); x = out_x_1; y = out_y_1; @@ -67,8 +65,6 @@ function f2() { }; var out_x_2, out_y_2; for (var _a = [{ a: 1, b: { c: 2 } }][0], x = _a.a, y = _a.b.c; x < y; ++x, --y) { - out_x_2 = x; - out_y_2 = y; var state_2 = _loop_2(x, y); x = out_x_2; y = out_y_2; diff --git a/tests/baselines/reference/nestedBlockScopedBindings3.js b/tests/baselines/reference/nestedBlockScopedBindings3.js index 4570e85d510..f9474381816 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings3.js +++ b/tests/baselines/reference/nestedBlockScopedBindings3.js @@ -127,7 +127,6 @@ function a4() { }; var out_x_1; for (var x = void 0; x < 1;) { - out_x_1 = x; _loop_5(x); x = out_x_1; } @@ -145,7 +144,6 @@ function a5() { }; var out_x_2; for (var x = void 0; x < 1;) { - out_x_2 = x; _loop_6(x); x = out_x_2; } diff --git a/tests/baselines/reference/nestedBlockScopedBindings4.js b/tests/baselines/reference/nestedBlockScopedBindings4.js index 832feb588bc..6b391070d93 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings4.js +++ b/tests/baselines/reference/nestedBlockScopedBindings4.js @@ -57,7 +57,6 @@ function a1() { }; var out_x_1; for (var x = void 0; x < 1;) { - out_x_1 = x; _loop_1(x); x = out_x_1; } @@ -76,7 +75,6 @@ function a2() { }; var out_x_2; for (var x = void 0;;) { - out_x_2 = x; _loop_2(x); x = out_x_2; } @@ -89,7 +87,6 @@ function a3() { }; var out_x_3; for (var x = void 0; x < 1;) { - out_x_3 = x; _loop_3(x); x = out_x_3; } @@ -100,7 +97,6 @@ function a3() { }; var out_x_4; for (var x = void 0;;) { - out_x_4 = x; _loop_4(x); x = out_x_4; } diff --git a/tests/baselines/reference/nestedBlockScopedBindings5.js b/tests/baselines/reference/nestedBlockScopedBindings5.js index af91e9999a6..df4fcf76423 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings5.js +++ b/tests/baselines/reference/nestedBlockScopedBindings5.js @@ -112,7 +112,6 @@ function a2() { }; var out_x_1; for (var x = void 0;;) { - out_x_1 = x; _loop_2(x); x = out_x_1; } @@ -132,7 +131,6 @@ function a3() { }; var out_x_2; for (var x = void 0; false;) { - out_x_2 = x; _loop_4(x); x = out_x_2; } @@ -169,7 +167,6 @@ function a5() { }; var out_x_3; for (var x = void 0; false;) { - out_x_3 = x; _loop_5(x); x = out_x_3; } diff --git a/tests/baselines/reference/nestedBlockScopedBindings6.js b/tests/baselines/reference/nestedBlockScopedBindings6.js index 43f61a23bbf..be9771471e9 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings6.js +++ b/tests/baselines/reference/nestedBlockScopedBindings6.js @@ -123,7 +123,6 @@ function a2() { }; var out_x_1; for (var x = void 0;;) { - out_x_1 = x; _loop_2(x); x = out_x_1; } @@ -144,7 +143,6 @@ function a3() { }; var out_x_2; for (var x = void 0;;) { - out_x_2 = x; _loop_4(x); x = out_x_2; } From dc1e23506c42b1d5609ae3f430e5bc8943299491 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 4 Feb 2016 14:10:02 -0800 Subject: [PATCH 031/102] fix test baselines --- tests/baselines/reference/arrayConcat2.symbols | 12 ++++++------ tests/baselines/reference/arrayConcat2.types | 12 ++++++------ tests/baselines/reference/arrayConcatMap.symbols | 4 ++-- tests/baselines/reference/arrayConcatMap.types | 4 ++-- tests/baselines/reference/concatError.symbols | 8 ++++---- tests/baselines/reference/concatError.types | 8 ++++---- .../reference/iteratorSpreadInArray6.errors.txt | 8 ++++++-- .../reference/iteratorSpreadInArray7.symbols | 4 ++-- .../baselines/reference/iteratorSpreadInArray7.types | 4 ++-- tests/baselines/reference/underscoreTest1.symbols | 4 ++-- tests/baselines/reference/underscoreTest1.types | 4 ++-- 11 files changed, 38 insertions(+), 34 deletions(-) diff --git a/tests/baselines/reference/arrayConcat2.symbols b/tests/baselines/reference/arrayConcat2.symbols index daedee6e9c8..fb84193c113 100644 --- a/tests/baselines/reference/arrayConcat2.symbols +++ b/tests/baselines/reference/arrayConcat2.symbols @@ -3,21 +3,21 @@ var a: string[] = []; >a : Symbol(a, Decl(arrayConcat2.ts, 0, 3)) a.concat("hello", 'world'); ->a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(arrayConcat2.ts, 0, 3)) ->concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) a.concat('Hello'); ->a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(arrayConcat2.ts, 0, 3)) ->concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) var b = new Array(); >b : Symbol(b, Decl(arrayConcat2.ts, 5, 3)) >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) b.concat('hello'); ->b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >b : Symbol(b, Decl(arrayConcat2.ts, 5, 3)) ->concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/arrayConcat2.types b/tests/baselines/reference/arrayConcat2.types index a49046c871f..b7df3749116 100644 --- a/tests/baselines/reference/arrayConcat2.types +++ b/tests/baselines/reference/arrayConcat2.types @@ -5,17 +5,17 @@ var a: string[] = []; a.concat("hello", 'world'); >a.concat("hello", 'world') : string[] ->a.concat : { (...items: U[]): string[]; (...items: string[]): string[]; } +>a.concat : (...items: (string | string[])[]) => string[] >a : string[] ->concat : { (...items: U[]): string[]; (...items: string[]): string[]; } +>concat : (...items: (string | string[])[]) => string[] >"hello" : string >'world' : string a.concat('Hello'); >a.concat('Hello') : string[] ->a.concat : { (...items: U[]): string[]; (...items: string[]): string[]; } +>a.concat : (...items: (string | string[])[]) => string[] >a : string[] ->concat : { (...items: U[]): string[]; (...items: string[]): string[]; } +>concat : (...items: (string | string[])[]) => string[] >'Hello' : string var b = new Array(); @@ -25,8 +25,8 @@ var b = new Array(); b.concat('hello'); >b.concat('hello') : string[] ->b.concat : { (...items: U[]): string[]; (...items: string[]): string[]; } +>b.concat : (...items: (string | string[])[]) => string[] >b : string[] ->concat : { (...items: U[]): string[]; (...items: string[]): string[]; } +>concat : (...items: (string | string[])[]) => string[] >'hello' : string diff --git a/tests/baselines/reference/arrayConcatMap.symbols b/tests/baselines/reference/arrayConcatMap.symbols index 5ef9d811723..bde2686e259 100644 --- a/tests/baselines/reference/arrayConcatMap.symbols +++ b/tests/baselines/reference/arrayConcatMap.symbols @@ -2,8 +2,8 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }]) >x : Symbol(x, Decl(arrayConcatMap.ts, 0, 3)) >[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --)) ->[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(arrayConcatMap.ts, 0, 20)) >a : Symbol(a, Decl(arrayConcatMap.ts, 0, 32)) diff --git a/tests/baselines/reference/arrayConcatMap.types b/tests/baselines/reference/arrayConcatMap.types index 11342ee848a..38e1a1c49c9 100644 --- a/tests/baselines/reference/arrayConcatMap.types +++ b/tests/baselines/reference/arrayConcatMap.types @@ -4,9 +4,9 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }]) >[].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a) : any[] >[].concat([{ a: 1 }], [{ a: 2 }]) .map : (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[] >[].concat([{ a: 1 }], [{ a: 2 }]) : any[] ->[].concat : { (...items: U[]): any[]; (...items: any[]): any[]; } +>[].concat : (...items: any[]) => any[] >[] : undefined[] ->concat : { (...items: U[]): any[]; (...items: any[]): any[]; } +>concat : (...items: any[]) => any[] >[{ a: 1 }] : { a: number; }[] >{ a: 1 } : { a: number; } >a : number diff --git a/tests/baselines/reference/concatError.symbols b/tests/baselines/reference/concatError.symbols index d4f04531fc7..23cc55c85be 100644 --- a/tests/baselines/reference/concatError.symbols +++ b/tests/baselines/reference/concatError.symbols @@ -14,15 +14,15 @@ var fa: number[]; fa = fa.concat([0]); >fa : Symbol(fa, Decl(concatError.ts, 8, 3)) ->fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >fa : Symbol(fa, Decl(concatError.ts, 8, 3)) ->concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) fa = fa.concat(0); >fa : Symbol(fa, Decl(concatError.ts, 8, 3)) ->fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>fa.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >fa : Symbol(fa, Decl(concatError.ts, 8, 3)) ->concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/concatError.types b/tests/baselines/reference/concatError.types index c264e0b0204..21a5cc5d089 100644 --- a/tests/baselines/reference/concatError.types +++ b/tests/baselines/reference/concatError.types @@ -16,9 +16,9 @@ fa = fa.concat([0]); >fa = fa.concat([0]) : number[] >fa : number[] >fa.concat([0]) : number[] ->fa.concat : { (...items: U[]): number[]; (...items: number[]): number[]; } +>fa.concat : (...items: (number | number[])[]) => number[] >fa : number[] ->concat : { (...items: U[]): number[]; (...items: number[]): number[]; } +>concat : (...items: (number | number[])[]) => number[] >[0] : number[] >0 : number @@ -26,9 +26,9 @@ fa = fa.concat(0); >fa = fa.concat(0) : number[] >fa : number[] >fa.concat(0) : number[] ->fa.concat : { (...items: U[]): number[]; (...items: number[]): number[]; } +>fa.concat : (...items: (number | number[])[]) => number[] >fa : number[] ->concat : { (...items: U[]): number[]; (...items: number[]): number[]; } +>concat : (...items: (number | number[])[]) => number[] >0 : number diff --git a/tests/baselines/reference/iteratorSpreadInArray6.errors.txt b/tests/baselines/reference/iteratorSpreadInArray6.errors.txt index b90ac5f203c..8148ce43de7 100644 --- a/tests/baselines/reference/iteratorSpreadInArray6.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray6.errors.txt @@ -1,11 +1,15 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(2,14): error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number'. +tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(2,14): error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. + Type 'symbol[]' is not assignable to type 'number[]'. + Type 'symbol' is not assignable to type 'number'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts (1 errors) ==== var array: number[] = [0, 1]; array.concat([...new SymbolIterator]); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. +!!! error TS2345: Type 'symbol[]' is not assignable to type 'number[]'. +!!! error TS2345: Type 'symbol' is not assignable to type 'number'. class SymbolIterator { next() { diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index e498e68b9eb..64521a9a33e 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -3,9 +3,9 @@ var array: symbol[]; >array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3)) array.concat([...new SymbolIterator]); ->array.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>array.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3)) ->concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) class SymbolIterator { diff --git a/tests/baselines/reference/iteratorSpreadInArray7.types b/tests/baselines/reference/iteratorSpreadInArray7.types index 6a279838060..f1dd8ebf855 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.types +++ b/tests/baselines/reference/iteratorSpreadInArray7.types @@ -4,9 +4,9 @@ var array: symbol[]; array.concat([...new SymbolIterator]); >array.concat([...new SymbolIterator]) : symbol[] ->array.concat : { (...items: U[]): symbol[]; (...items: symbol[]): symbol[]; } +>array.concat : (...items: (symbol | symbol[])[]) => symbol[] >array : symbol[] ->concat : { (...items: U[]): symbol[]; (...items: symbol[]): symbol[]; } +>concat : (...items: (symbol | symbol[])[]) => symbol[] >[...new SymbolIterator] : symbol[] >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator diff --git a/tests/baselines/reference/underscoreTest1.symbols b/tests/baselines/reference/underscoreTest1.symbols index 9de509de417..ee8460e16ed 100644 --- a/tests/baselines/reference/underscoreTest1.symbols +++ b/tests/baselines/reference/underscoreTest1.symbols @@ -71,9 +71,9 @@ var flat = _.reduceRight(list, (a, b) => a.concat(b), []); >list : Symbol(list, Decl(underscoreTest1_underscoreTests.ts, 13, 3)) >a : Symbol(a, Decl(underscoreTest1_underscoreTests.ts, 14, 32)) >b : Symbol(b, Decl(underscoreTest1_underscoreTests.ts, 14, 34)) ->a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(underscoreTest1_underscoreTests.ts, 14, 32)) ->concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --)) >b : Symbol(b, Decl(underscoreTest1_underscoreTests.ts, 14, 34)) var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 7fe233c4490..4d8a05a5c38 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -124,9 +124,9 @@ var flat = _.reduceRight(list, (a, b) => a.concat(b), []); >a : number[] >b : number[] >a.concat(b) : number[] ->a.concat : { (...items: U[]): number[]; (...items: number[]): number[]; } +>a.concat : (...items: (number | number[])[]) => number[] >a : number[] ->concat : { (...items: U[]): number[]; (...items: number[]): number[]; } +>concat : (...items: (number | number[])[]) => number[] >b : number[] >[] : undefined[] From f35ab8c62043242c8579fb43486b74ea9076ecad Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 4 Feb 2016 14:18:23 -0800 Subject: [PATCH 032/102] Port fix6901 from release-1.8 to master Fix where we start checking for super-call Update baselines Address PR --- src/compiler/checker.ts | 4 -- src/compiler/emitter.ts | 34 +++++++++------- src/compiler/utilities.ts | 4 ++ ...BeforeEmitParameterPropertyDeclaration1.js | 37 ++++++++++++++++++ ...eEmitParameterPropertyDeclaration1.symbols | 23 +++++++++++ ...oreEmitParameterPropertyDeclaration1.types | 29 ++++++++++++++ ...oreEmitParameterPropertyDeclaration1ES6.js | 29 ++++++++++++++ ...itParameterPropertyDeclaration1ES6.symbols | 23 +++++++++++ ...EmitParameterPropertyDeclaration1ES6.types | 29 ++++++++++++++ ...SuperCallBeforeEmitPropertyDeclaration1.js | 39 +++++++++++++++++++ ...CallBeforeEmitPropertyDeclaration1.symbols | 23 +++++++++++ ...erCallBeforeEmitPropertyDeclaration1.types | 30 ++++++++++++++ ...erCallBeforeEmitPropertyDeclaration1ES6.js | 29 ++++++++++++++ ...lBeforeEmitPropertyDeclaration1ES6.symbols | 22 +++++++++++ ...allBeforeEmitPropertyDeclaration1ES6.types | 27 +++++++++++++ ...arationAndParameterPropertyDeclaration1.js | 38 ++++++++++++++++++ ...onAndParameterPropertyDeclaration1.symbols | 25 ++++++++++++ ...tionAndParameterPropertyDeclaration1.types | 32 +++++++++++++++ ...tionAndParameterPropertyDeclaration1ES6.js | 30 ++++++++++++++ ...ndParameterPropertyDeclaration1ES6.symbols | 25 ++++++++++++ ...nAndParameterPropertyDeclaration1ES6.types | 32 +++++++++++++++ .../reference/strictModeInConstructor.js | 2 +- 22 files changed, 548 insertions(+), 18 deletions(-) create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.symbols create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.symbols create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.symbols create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.symbols create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.symbols create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.symbols create mode 100644 tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 65cb3df785f..63a4185a8bb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11834,10 +11834,6 @@ namespace ts { return; } - function isSuperCallExpression(n: Node): boolean { - return n.kind === SyntaxKind.CallExpression && (n).expression.kind === SyntaxKind.SuperKeyword; - } - function containsSuperCallAsComputedPropertyName(n: Declaration): boolean { return n.name && containsSuperCall(n.name); } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index aba0c883aaa..52ee502b25f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4895,18 +4895,24 @@ const _super = (function (geti, seti) { emitToken(SyntaxKind.CloseBraceToken, body.statements.end); } - function findInitialSuperCall(ctor: ConstructorDeclaration): ExpressionStatement { - if (ctor.body) { - const statement = (ctor.body).statements[0]; - if (statement && statement.kind === SyntaxKind.ExpressionStatement) { - const expr = (statement).expression; - if (expr && expr.kind === SyntaxKind.CallExpression) { - const func = (expr).expression; - if (func && func.kind === SyntaxKind.SuperKeyword) { - return statement; - } - } - } + /** + * Return the statement at a given index if it is a super-call statement + * @param ctor a constructor declaration + * @param index an index to constructor's body to check + */ + function getSuperCallAtGivenIndex(ctor: ConstructorDeclaration, index: number): ExpressionStatement { + if (!ctor.body) { + return undefined; + } + const statements = ctor.body.statements; + + if (!statements || index >= statements.length) { + return undefined; + } + + const statement = statements[index]; + if (statement.kind === SyntaxKind.ExpressionStatement) { + return isSuperCallExpression((statement).expression) ? statement : undefined; } } @@ -5190,13 +5196,15 @@ const _super = (function (geti, seti) { if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); + if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); + superCall = getSuperCallAtGivenIndex(ctor, startIndex); if (superCall) { writeLine(); emit(superCall); } } + emitParameterPropertyAssignments(ctor); } else { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 8f66e43c1d6..09100eb61ed 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -464,6 +464,10 @@ namespace ts { return !!(getCombinedNodeFlags(node) & NodeFlags.Let); } + export function isSuperCallExpression(n: Node): boolean { + return n.kind === SyntaxKind.CallExpression && (n).expression.kind === SyntaxKind.SuperKeyword; + } + export function isPrologueDirective(node: Node): boolean { return node.kind === SyntaxKind.ExpressionStatement && (node).expression.kind === SyntaxKind.StringLiteral; } diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js new file mode 100644 index 00000000000..88ce3f1418b --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js @@ -0,0 +1,37 @@ +//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts] +class A { + blub = 6; +} + + +class B extends A { + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + + +//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + this.blub = 6; + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B(x) { + "use strict"; + 'someStringForEgngInject'; + _super.call(this); + this.x = x; + } + return B; +}(A)); diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.symbols new file mode 100644 index 00000000000..3931a7115f6 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 0)) + + constructor(public x: number) { +>x : Symbol(x, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 6, 16)) + + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types new file mode 100644 index 00000000000..cfdf0af0300 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + constructor(public x: number) { +>x : number + + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} + diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js new file mode 100644 index 00000000000..2e594dba0ec --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js @@ -0,0 +1,29 @@ +//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts] +class A { + blub = 6; +} + + +class B extends A { + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + + +//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js] +class A { + constructor() { + this.blub = 6; + } +} +class B extends A { + constructor(x) { + "use strict"; + 'someStringForEgngInject'; + super(); + this.x = x; + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.symbols new file mode 100644 index 00000000000..8b8c09f2611 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 0)) + + constructor(public x: number) { +>x : Symbol(x, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 6, 16)) + + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types new file mode 100644 index 00000000000..4424042c241 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + constructor(public x: number) { +>x : number + + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} + diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js new file mode 100644 index 00000000000..920ad1f7bda --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js @@ -0,0 +1,39 @@ +//// [emitSuperCallBeforeEmitPropertyDeclaration1.ts] +class A { + blub = 6; +} + + +class B extends A { + + blub = 12; + + constructor() { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + +//// [emitSuperCallBeforeEmitPropertyDeclaration1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + this.blub = 6; + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B() { + "use strict"; + 'someStringForEgngInject'; + _super.call(this); + this.blub = 12; + } + return B; +}(A)); diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.symbols new file mode 100644 index 00000000000..0b118b7c991 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 0)) + + blub = 12; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 5, 19)) + + constructor() { + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types new file mode 100644 index 00000000000..2d16fed121d --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + blub = 12; +>blub : number +>12 : number + + constructor() { + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js new file mode 100644 index 00000000000..4b3e9e73b9f --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js @@ -0,0 +1,29 @@ +//// [emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts] +class A { + blub = 6; +} + + +class B extends A { + + blub = 12; + + constructor() { + 'someStringForEgngInject'; + super() + } +} + +//// [emitSuperCallBeforeEmitPropertyDeclaration1ES6.js] +class A { + constructor() { + this.blub = 6; + } +} +class B extends A { + constructor() { + 'someStringForEgngInject'; + super(); + this.blub = 12; + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.symbols new file mode 100644 index 00000000000..4d4b01a3666 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 0)) + + blub = 12; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 5, 19)) + + constructor() { + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types new file mode 100644 index 00000000000..39e8f885777 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + blub = 12; +>blub : number +>12 : number + + constructor() { + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js new file mode 100644 index 00000000000..3fa18140034 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js @@ -0,0 +1,38 @@ +//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts] +class A { + blub = 6; +} + + +class B extends A { + blah = 2; + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + +//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + this.blub = 6; + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B(x) { + "use strict"; + 'someStringForEgngInject'; + _super.call(this); + this.x = x; + this.blah = 2; + } + return B; +}(A)); diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.symbols new file mode 100644 index 00000000000..1fb4ed01d85 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 0)) + + blah = 2; +>blah : Symbol(blah, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 5, 19)) + + constructor(public x: number) { +>x : Symbol(x, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 7, 16)) + + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types new file mode 100644 index 00000000000..acb5703581a --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + blah = 2; +>blah : number +>2 : number + + constructor(public x: number) { +>x : number + + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js new file mode 100644 index 00000000000..5e27acf8d9a --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js @@ -0,0 +1,30 @@ +//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts] +class A { + blub = 6; +} + + +class B extends A { + blah = 2; + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + +//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js] +class A { + constructor() { + this.blub = 6; + } +} +class B extends A { + constructor(x) { + "use strict"; + 'someStringForEgngInject'; + super(); + this.x = x; + this.blah = 2; + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.symbols new file mode 100644 index 00000000000..41cb20f3841 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 0)) + + blah = 2; +>blah : Symbol(blah, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 5, 19)) + + constructor(public x: number) { +>x : Symbol(x, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 7, 16)) + + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types new file mode 100644 index 00000000000..96fc1fc2dc3 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + blah = 2; +>blah : number +>2 : number + + constructor(public x: number) { +>x : number + + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index 3b315861548..bcfbdf22414 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -75,8 +75,8 @@ var B = (function (_super) { __extends(B, _super); function B() { "use strict"; // No error - this.s = 9; _super.call(this); + this.s = 9; } return B; }(A)); From 95396cc2bcc925db4e820aa05d053bcf5e0950e9 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Fri, 5 Feb 2016 21:03:27 +0000 Subject: [PATCH 033/102] spelling fixes for services.ts * aliases * analyze * asterisks * constructor * diagnostic * existing * referring * revisiting * search * source * visible --- src/services/services.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 211b1358c50..78c0f57ccf8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -502,7 +502,7 @@ namespace ts { spacesToRemoveAfterAsterisk = 0; } - // Analyse text on this line + // Analyze text on this line while (pos < end && !isLineBreak(sourceFile.text.charCodeAt(pos))) { const ch = sourceFile.text.charAt(pos); if (ch === "@") { @@ -641,7 +641,7 @@ namespace ts { paramHelpStringMargin = undefined; } - // If this is the start of another tag, continue with the loop in seach of param tag with symbol name + // If this is the start of another tag, continue with the loop in search of param tag with symbol name if (sourceFile.text.charCodeAt(pos) === CharacterCodes.at) { continue; } @@ -2822,7 +2822,7 @@ namespace ts { } // Check if the language version has changed since we last created a program; if they are the same, - // it is safe to reuse the souceFiles; if not, then the shape of the AST can change, and the oldSourceFile + // it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile // can not be reused. we have to dump all syntax trees and create new ones. if (!changesInCompilationSettingsAffectSyntax) { // Check if the old program had this file already @@ -2916,7 +2916,7 @@ namespace ts { } /** - * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors + * getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors * If '-d' enabled, report both semantic and emitter errors */ function getSemanticDiagnostics(fileName: string): Diagnostic[] { @@ -3725,7 +3725,7 @@ namespace ts { * do not occur at the current position and have not otherwise been typed. */ function filterNamedImportOrExportCompletionItems(exportsOfModule: Symbol[], namedImportsOrExports: ImportOrExportSpecifier[]): Symbol[] { - const exisingImportsOrExports: Map = {}; + const existingImportsOrExports: Map = {}; for (const element of namedImportsOrExports) { // If this is the current item we are editing right now, do not filter it out @@ -3734,14 +3734,14 @@ namespace ts { } const name = element.propertyName || element.name; - exisingImportsOrExports[name.text] = true; + existingImportsOrExports[name.text] = true; } - if (isEmpty(exisingImportsOrExports)) { + if (isEmpty(existingImportsOrExports)) { return exportsOfModule; } - return filter(exportsOfModule, e => !lookUp(exisingImportsOrExports, e.name)); + return filter(exportsOfModule, e => !lookUp(existingImportsOrExports, e.name)); } /** @@ -5574,7 +5574,7 @@ namespace ts { } // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visibile outside its declaration scope. + // So consider it visible outside its declaration scope. if (symbol.flags & SymbolFlags.Alias) { return undefined; } @@ -5974,12 +5974,12 @@ namespace ts { // The search set contains at least the current symbol let result = [symbol]; - // If the symbol is an alias, add what it alaises to the list + // If the symbol is an alias, add what it aliases to the list if (isImportSpecifierSymbol(symbol)) { result.push(typeChecker.getAliasedSymbol(symbol)); } - // For export specifiers, the exported name can be refering to a local symbol, e.g.: + // For export specifiers, the exported name can be referring to a local symbol, e.g.: // import {a} from "mod"; // export {a as somethingElse} // We want the *local* declaration of 'a' as declared in the import, @@ -6015,7 +6015,7 @@ namespace ts { // If the symbol.valueDeclaration is a property parameter declaration, // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in contructor.locals. + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter && isParameterPropertyDeclaration(symbol.valueDeclaration)) { @@ -6041,9 +6041,9 @@ namespace ts { /** * Find symbol of the given property-name and add the symbol to the given result array * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to serach for + * @param propertyName a name of property to search for * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisitng of the same symbol. + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. * The value of previousIterationSymbol is undefined when the function is first called. */ function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[], @@ -7386,12 +7386,12 @@ namespace ts { // comment portion. const singleLineCommentStart = /(?:\/\/+\s*)/.source; const multiLineCommentStart = /(?:\/\*+\s*)/.source; - const anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; + const anyNumberOfSpacesAndAsterisksAtStartOfLine = /(?:^(?:\s|\*)*)/.source; // Match any of the above three TODO comment start regexps. // Note that the outermost group *is* a capture group. We want to capture the preamble // so that we can determine the starting position of the TODO comment match. - const preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + const preamble = "(" + anyNumberOfSpacesAndAsterisksAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; // Takes the descriptors and forms a regexp that matches them as if they were literals. // For example, if the descriptors are "TODO(jason)" and "HACK", then this will be: From 6f804e40efc6cdc153f9aee594382df74aa8db0c Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 5 Feb 2016 16:30:01 -0800 Subject: [PATCH 034/102] change flag name --- src/compiler/commandLineParser.ts | 2 +- src/compiler/emitter.ts | 8 ++++---- src/compiler/types.ts | 2 +- .../baselines/reference/emitNonStrictModules_amd.symbols | 5 ----- tests/baselines/reference/emitNonStrictModules_amd.types | 6 ------ .../baselines/reference/emitNonStrictModules_commonjs.js | 6 ------ .../reference/emitNonStrictModules_commonjs.symbols | 5 ----- .../reference/emitNonStrictModules_commonjs.types | 6 ------ tests/baselines/reference/emitNonStrictModules_es6.js | 6 ------ .../baselines/reference/emitNonStrictModules_es6.symbols | 5 ----- tests/baselines/reference/emitNonStrictModules_es6.types | 6 ------ .../reference/emitNonStrictModules_system.symbols | 5 ----- .../baselines/reference/emitNonStrictModules_system.types | 6 ------ .../baselines/reference/emitNonStrictModules_umd.symbols | 5 ----- tests/baselines/reference/emitNonStrictModules_umd.types | 6 ------ ...NonStrictModules_amd.js => noImplicitUseStrict_amd.js} | 4 ++-- tests/baselines/reference/noImplicitUseStrict_amd.symbols | 5 +++++ tests/baselines/reference/noImplicitUseStrict_amd.types | 6 ++++++ tests/baselines/reference/noImplicitUseStrict_commonjs.js | 6 ++++++ .../reference/noImplicitUseStrict_commonjs.symbols | 5 +++++ .../reference/noImplicitUseStrict_commonjs.types | 6 ++++++ tests/baselines/reference/noImplicitUseStrict_es6.js | 6 ++++++ tests/baselines/reference/noImplicitUseStrict_es6.symbols | 5 +++++ tests/baselines/reference/noImplicitUseStrict_es6.types | 6 ++++++ ...ictModules_system.js => noImplicitUseStrict_system.js} | 4 ++-- .../reference/noImplicitUseStrict_system.symbols | 5 +++++ .../baselines/reference/noImplicitUseStrict_system.types | 6 ++++++ ...NonStrictModules_umd.js => noImplicitUseStrict_umd.js} | 4 ++-- tests/baselines/reference/noImplicitUseStrict_umd.symbols | 5 +++++ tests/baselines/reference/noImplicitUseStrict_umd.types | 6 ++++++ tests/cases/compiler/emitNonStrictModules_amd.ts | 4 ---- tests/cases/compiler/emitNonStrictModules_commonjs.ts | 4 ---- tests/cases/compiler/emitNonStrictModules_es6.ts | 5 ----- tests/cases/compiler/emitNonStrictModules_system.ts | 4 ---- tests/cases/compiler/emitNonStrictModules_umd.ts | 4 ---- tests/cases/compiler/noImplicitUseStrict_amd.ts | 4 ++++ tests/cases/compiler/noImplicitUseStrict_commonjs.ts | 4 ++++ tests/cases/compiler/noImplicitUseStrict_es6.ts | 5 +++++ tests/cases/compiler/noImplicitUseStrict_system.ts | 4 ++++ tests/cases/compiler/noImplicitUseStrict_umd.ts | 4 ++++ 40 files changed, 100 insertions(+), 100 deletions(-) delete mode 100644 tests/baselines/reference/emitNonStrictModules_amd.symbols delete mode 100644 tests/baselines/reference/emitNonStrictModules_amd.types delete mode 100644 tests/baselines/reference/emitNonStrictModules_commonjs.js delete mode 100644 tests/baselines/reference/emitNonStrictModules_commonjs.symbols delete mode 100644 tests/baselines/reference/emitNonStrictModules_commonjs.types delete mode 100644 tests/baselines/reference/emitNonStrictModules_es6.js delete mode 100644 tests/baselines/reference/emitNonStrictModules_es6.symbols delete mode 100644 tests/baselines/reference/emitNonStrictModules_es6.types delete mode 100644 tests/baselines/reference/emitNonStrictModules_system.symbols delete mode 100644 tests/baselines/reference/emitNonStrictModules_system.types delete mode 100644 tests/baselines/reference/emitNonStrictModules_umd.symbols delete mode 100644 tests/baselines/reference/emitNonStrictModules_umd.types rename tests/baselines/reference/{emitNonStrictModules_amd.js => noImplicitUseStrict_amd.js} (57%) create mode 100644 tests/baselines/reference/noImplicitUseStrict_amd.symbols create mode 100644 tests/baselines/reference/noImplicitUseStrict_amd.types create mode 100644 tests/baselines/reference/noImplicitUseStrict_commonjs.js create mode 100644 tests/baselines/reference/noImplicitUseStrict_commonjs.symbols create mode 100644 tests/baselines/reference/noImplicitUseStrict_commonjs.types create mode 100644 tests/baselines/reference/noImplicitUseStrict_es6.js create mode 100644 tests/baselines/reference/noImplicitUseStrict_es6.symbols create mode 100644 tests/baselines/reference/noImplicitUseStrict_es6.types rename tests/baselines/reference/{emitNonStrictModules_system.js => noImplicitUseStrict_system.js} (73%) create mode 100644 tests/baselines/reference/noImplicitUseStrict_system.symbols create mode 100644 tests/baselines/reference/noImplicitUseStrict_system.types rename tests/baselines/reference/{emitNonStrictModules_umd.js => noImplicitUseStrict_umd.js} (81%) create mode 100644 tests/baselines/reference/noImplicitUseStrict_umd.symbols create mode 100644 tests/baselines/reference/noImplicitUseStrict_umd.types delete mode 100644 tests/cases/compiler/emitNonStrictModules_amd.ts delete mode 100644 tests/cases/compiler/emitNonStrictModules_commonjs.ts delete mode 100644 tests/cases/compiler/emitNonStrictModules_es6.ts delete mode 100644 tests/cases/compiler/emitNonStrictModules_system.ts delete mode 100644 tests/cases/compiler/emitNonStrictModules_umd.ts create mode 100644 tests/cases/compiler/noImplicitUseStrict_amd.ts create mode 100644 tests/cases/compiler/noImplicitUseStrict_commonjs.ts create mode 100644 tests/cases/compiler/noImplicitUseStrict_es6.ts create mode 100644 tests/cases/compiler/noImplicitUseStrict_system.ts create mode 100644 tests/cases/compiler/noImplicitUseStrict_umd.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 957b38c67de..065fb3a9737 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -322,7 +322,7 @@ namespace ts { description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { - name: "emitNonStrictModules", + name: "noImplicitUseStrict", type: "boolean", description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 15edb022b11..7d602c58400 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7179,7 +7179,7 @@ const _super = (function (geti, seti) { write(`], function(${exportFunctionForFile}, ${contextObjectForFile}) {`); writeLine(); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.emitNonStrictModules); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); writeLine(); write(`var __moduleName = ${contextObjectForFile} && ${contextObjectForFile}.id;`); writeLine(); @@ -7285,7 +7285,7 @@ const _super = (function (geti, seti) { writeModuleName(node, emitRelativePathAsModuleName); emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/!compilerOptions.emitNonStrictModules); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/!compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -7297,7 +7297,7 @@ const _super = (function (geti, seti) { } function emitCommonJSModule(node: SourceFile) { - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.emitNonStrictModules); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -7326,7 +7326,7 @@ const _super = (function (geti, seti) { })(`); emitAMDFactoryHeader(dependencyNames); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.emitNonStrictModules); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 90a6a9a6752..1b992bb11ef 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2422,7 +2422,7 @@ namespace ts { traceModuleResolution?: boolean; allowSyntheticDefaultImports?: boolean; allowJs?: boolean; - emitNonStrictModules?: boolean; + noImplicitUseStrict?: boolean; /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. diff --git a/tests/baselines/reference/emitNonStrictModules_amd.symbols b/tests/baselines/reference/emitNonStrictModules_amd.symbols deleted file mode 100644 index 1590ea05ad4..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_amd.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_amd.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitNonStrictModules_amd.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitNonStrictModules_amd.types b/tests/baselines/reference/emitNonStrictModules_amd.types deleted file mode 100644 index 650df648d8d..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_amd.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_amd.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitNonStrictModules_commonjs.js b/tests/baselines/reference/emitNonStrictModules_commonjs.js deleted file mode 100644 index 7a2d0720015..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_commonjs.js +++ /dev/null @@ -1,6 +0,0 @@ -//// [emitNonStrictModules_commonjs.ts] - -export var x = 0; - -//// [emitNonStrictModules_commonjs.js] -exports.x = 0; diff --git a/tests/baselines/reference/emitNonStrictModules_commonjs.symbols b/tests/baselines/reference/emitNonStrictModules_commonjs.symbols deleted file mode 100644 index 36b487f34d1..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_commonjs.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_commonjs.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitNonStrictModules_commonjs.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitNonStrictModules_commonjs.types b/tests/baselines/reference/emitNonStrictModules_commonjs.types deleted file mode 100644 index f8a24d53641..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_commonjs.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_commonjs.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitNonStrictModules_es6.js b/tests/baselines/reference/emitNonStrictModules_es6.js deleted file mode 100644 index 535afff7730..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_es6.js +++ /dev/null @@ -1,6 +0,0 @@ -//// [emitNonStrictModules_es6.ts] - -export var x = 0; - -//// [emitNonStrictModules_es6.js] -export var x = 0; diff --git a/tests/baselines/reference/emitNonStrictModules_es6.symbols b/tests/baselines/reference/emitNonStrictModules_es6.symbols deleted file mode 100644 index 884189014b0..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_es6.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_es6.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitNonStrictModules_es6.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitNonStrictModules_es6.types b/tests/baselines/reference/emitNonStrictModules_es6.types deleted file mode 100644 index f3208e247da..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_es6.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_es6.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitNonStrictModules_system.symbols b/tests/baselines/reference/emitNonStrictModules_system.symbols deleted file mode 100644 index b772eafe447..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_system.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_system.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitNonStrictModules_system.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitNonStrictModules_system.types b/tests/baselines/reference/emitNonStrictModules_system.types deleted file mode 100644 index 352381db379..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_system.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_system.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitNonStrictModules_umd.symbols b/tests/baselines/reference/emitNonStrictModules_umd.symbols deleted file mode 100644 index 23af4139243..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_umd.symbols +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_umd.ts === - -export var x = 0; ->x : Symbol(x, Decl(emitNonStrictModules_umd.ts, 1, 10)) - diff --git a/tests/baselines/reference/emitNonStrictModules_umd.types b/tests/baselines/reference/emitNonStrictModules_umd.types deleted file mode 100644 index 83c55b1d4cd..00000000000 --- a/tests/baselines/reference/emitNonStrictModules_umd.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/compiler/emitNonStrictModules_umd.ts === - -export var x = 0; ->x : number ->0 : number - diff --git a/tests/baselines/reference/emitNonStrictModules_amd.js b/tests/baselines/reference/noImplicitUseStrict_amd.js similarity index 57% rename from tests/baselines/reference/emitNonStrictModules_amd.js rename to tests/baselines/reference/noImplicitUseStrict_amd.js index f2a746280ac..ac15f548c47 100644 --- a/tests/baselines/reference/emitNonStrictModules_amd.js +++ b/tests/baselines/reference/noImplicitUseStrict_amd.js @@ -1,8 +1,8 @@ -//// [emitNonStrictModules_amd.ts] +//// [noImplicitUseStrict_amd.ts] export var x = 0; -//// [emitNonStrictModules_amd.js] +//// [noImplicitUseStrict_amd.js] define(["require", "exports"], function (require, exports) { exports.x = 0; }); diff --git a/tests/baselines/reference/noImplicitUseStrict_amd.symbols b/tests/baselines/reference/noImplicitUseStrict_amd.symbols new file mode 100644 index 00000000000..de1faa2213c --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_amd.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_amd.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_amd.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_amd.types b/tests/baselines/reference/noImplicitUseStrict_amd.types new file mode 100644 index 00000000000..c9e1b5749dc --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_amd.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_amd.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/noImplicitUseStrict_commonjs.js b/tests/baselines/reference/noImplicitUseStrict_commonjs.js new file mode 100644 index 00000000000..9c726938f04 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_commonjs.js @@ -0,0 +1,6 @@ +//// [noImplicitUseStrict_commonjs.ts] + +export var x = 0; + +//// [noImplicitUseStrict_commonjs.js] +exports.x = 0; diff --git a/tests/baselines/reference/noImplicitUseStrict_commonjs.symbols b/tests/baselines/reference/noImplicitUseStrict_commonjs.symbols new file mode 100644 index 00000000000..af53dc272d2 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_commonjs.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_commonjs.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_commonjs.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_commonjs.types b/tests/baselines/reference/noImplicitUseStrict_commonjs.types new file mode 100644 index 00000000000..9999d3b94ba --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_commonjs.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_commonjs.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/noImplicitUseStrict_es6.js b/tests/baselines/reference/noImplicitUseStrict_es6.js new file mode 100644 index 00000000000..27dbbc7ea79 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_es6.js @@ -0,0 +1,6 @@ +//// [noImplicitUseStrict_es6.ts] + +export var x = 0; + +//// [noImplicitUseStrict_es6.js] +export var x = 0; diff --git a/tests/baselines/reference/noImplicitUseStrict_es6.symbols b/tests/baselines/reference/noImplicitUseStrict_es6.symbols new file mode 100644 index 00000000000..31bc1904ff9 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_es6.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_es6.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_es6.types b/tests/baselines/reference/noImplicitUseStrict_es6.types new file mode 100644 index 00000000000..838c7316be0 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_es6.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitNonStrictModules_system.js b/tests/baselines/reference/noImplicitUseStrict_system.js similarity index 73% rename from tests/baselines/reference/emitNonStrictModules_system.js rename to tests/baselines/reference/noImplicitUseStrict_system.js index f1ad93f0009..cf5a7e1b261 100644 --- a/tests/baselines/reference/emitNonStrictModules_system.js +++ b/tests/baselines/reference/noImplicitUseStrict_system.js @@ -1,8 +1,8 @@ -//// [emitNonStrictModules_system.ts] +//// [noImplicitUseStrict_system.ts] export var x = 0; -//// [emitNonStrictModules_system.js] +//// [noImplicitUseStrict_system.js] System.register([], function(exports_1, context_1) { var __moduleName = context_1 && context_1.id; var x; diff --git a/tests/baselines/reference/noImplicitUseStrict_system.symbols b/tests/baselines/reference/noImplicitUseStrict_system.symbols new file mode 100644 index 00000000000..62b89a6593d --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_system.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_system.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_system.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_system.types b/tests/baselines/reference/noImplicitUseStrict_system.types new file mode 100644 index 00000000000..1da563f938b --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_system.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_system.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/emitNonStrictModules_umd.js b/tests/baselines/reference/noImplicitUseStrict_umd.js similarity index 81% rename from tests/baselines/reference/emitNonStrictModules_umd.js rename to tests/baselines/reference/noImplicitUseStrict_umd.js index c1ee0c048c5..ca252daeb9d 100644 --- a/tests/baselines/reference/emitNonStrictModules_umd.js +++ b/tests/baselines/reference/noImplicitUseStrict_umd.js @@ -1,8 +1,8 @@ -//// [emitNonStrictModules_umd.ts] +//// [noImplicitUseStrict_umd.ts] export var x = 0; -//// [emitNonStrictModules_umd.js] +//// [noImplicitUseStrict_umd.js] (function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; diff --git a/tests/baselines/reference/noImplicitUseStrict_umd.symbols b/tests/baselines/reference/noImplicitUseStrict_umd.symbols new file mode 100644 index 00000000000..a72a251ad09 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_umd.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_umd.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_umd.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_umd.types b/tests/baselines/reference/noImplicitUseStrict_umd.types new file mode 100644 index 00000000000..6a3fd6ece77 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_umd.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_umd.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/cases/compiler/emitNonStrictModules_amd.ts b/tests/cases/compiler/emitNonStrictModules_amd.ts deleted file mode 100644 index 217e23d91a3..00000000000 --- a/tests/cases/compiler/emitNonStrictModules_amd.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @module: amd -// @emitNonStrictModules: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitNonStrictModules_commonjs.ts b/tests/cases/compiler/emitNonStrictModules_commonjs.ts deleted file mode 100644 index 3d29c30176f..00000000000 --- a/tests/cases/compiler/emitNonStrictModules_commonjs.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @module: commonjs -// @emitNonStrictModules: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitNonStrictModules_es6.ts b/tests/cases/compiler/emitNonStrictModules_es6.ts deleted file mode 100644 index 426c5aff533..00000000000 --- a/tests/cases/compiler/emitNonStrictModules_es6.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @module: es6 -// @target: es6 -// @emitNonStrictModules: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitNonStrictModules_system.ts b/tests/cases/compiler/emitNonStrictModules_system.ts deleted file mode 100644 index 23801462b71..00000000000 --- a/tests/cases/compiler/emitNonStrictModules_system.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @module: system -// @emitNonStrictModules: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/emitNonStrictModules_umd.ts b/tests/cases/compiler/emitNonStrictModules_umd.ts deleted file mode 100644 index 1166f512cf2..00000000000 --- a/tests/cases/compiler/emitNonStrictModules_umd.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @module: umd -// @emitNonStrictModules: true - -export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_amd.ts b/tests/cases/compiler/noImplicitUseStrict_amd.ts new file mode 100644 index 00000000000..3a2a4760221 --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_amd.ts @@ -0,0 +1,4 @@ +// @module: amd +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_commonjs.ts b/tests/cases/compiler/noImplicitUseStrict_commonjs.ts new file mode 100644 index 00000000000..f8377dba07a --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_commonjs.ts @@ -0,0 +1,4 @@ +// @module: commonjs +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_es6.ts b/tests/cases/compiler/noImplicitUseStrict_es6.ts new file mode 100644 index 00000000000..f56b0fd9021 --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_es6.ts @@ -0,0 +1,5 @@ +// @module: es6 +// @target: es6 +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_system.ts b/tests/cases/compiler/noImplicitUseStrict_system.ts new file mode 100644 index 00000000000..37ff5de469d --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_system.ts @@ -0,0 +1,4 @@ +// @module: system +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_umd.ts b/tests/cases/compiler/noImplicitUseStrict_umd.ts new file mode 100644 index 00000000000..f26f2ee2aff --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_umd.ts @@ -0,0 +1,4 @@ +// @module: umd +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file From b9e26e7649f73fa449e4339eb12402d5d8e87def Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 6 Feb 2016 08:37:09 -0800 Subject: [PATCH 035/102] Correct handling of intersection types in allConstituentTypesHaveKind --- src/compiler/checker.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 65cb3df785f..6fd464c38bc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10337,9 +10337,8 @@ namespace ts { const widenedType = getWidenedType(exprType); // Permit 'number[] | "foo"' to be asserted to 'string'. - const bothAreStringLike = - someConstituentTypeHasKind(targetType, TypeFlags.StringLike) && - someConstituentTypeHasKind(widenedType, TypeFlags.StringLike); + const bothAreStringLike = someConstituentTypeHasKind(targetType, TypeFlags.StringLike) && + someConstituentTypeHasKind(widenedType, TypeFlags.StringLike); if (!bothAreStringLike && !(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } @@ -10594,7 +10593,7 @@ namespace ts { } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType === voidType || isTypeAny(returnType) || (returnType && (returnType.flags & TypeFlags.Union) && someConstituentTypeHasKind(returnType, TypeFlags.Any | TypeFlags.Void))) { + if (returnType && someConstituentTypeHasKind(returnType, TypeFlags.Any | TypeFlags.Void)) { return; } @@ -10882,38 +10881,47 @@ namespace ts { return numberType; } - // Just like isTypeOfKind below, except that it returns true if *any* constituent - // has this kind. + // Return true if type might be of the given kind. A union or intersection type might be of a given + // kind if at least one constituent type is of the given kind. function someConstituentTypeHasKind(type: Type, kind: TypeFlags): boolean { if (type.flags & kind) { return true; } if (type.flags & TypeFlags.UnionOrIntersection) { const types = (type).types; - for (const current of types) { - if (current.flags & kind) { + for (const t of types) { + if (someConstituentTypeHasKind(t, kind)) { return true; } } - return false; } return false; } - // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. + // Return true if type is of the given kind. A union type is of a given kind if all constituent types + // are of the given kind. An intersection type is of a given kind if at least one constituent type is + // of the given kind. function allConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean { if (type.flags & kind) { return true; } - if (type.flags & TypeFlags.UnionOrIntersection) { + if (type.flags & TypeFlags.Union) { const types = (type).types; - for (const current of types) { - if (!(current.flags & kind)) { + for (const t of types) { + if (!allConstituentTypesHaveKind(t, kind)) { return false; } } return true; } + if (type.flags & TypeFlags.Intersection) { + const types = (type).types; + for (const t of types) { + if (allConstituentTypesHaveKind(t, kind)) { + return true; + } + } + } return false; } From 6f85e13c72763443d758a1f473fcc49796472e0a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 6 Feb 2016 08:39:31 -0800 Subject: [PATCH 036/102] Rename allConstituentTypesHaveKind/someConstituentTypeHasKind to isTypeOfKind/maybeTypeOfKind --- src/compiler/checker.ts | 52 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6fd464c38bc..22280a05725 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5591,7 +5591,7 @@ namespace ts { } function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { - if (!(target.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties) && someConstituentTypeHasKind(target, TypeFlags.ObjectType)) { + if (!(target.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties) && maybeTypeOfKind(target, TypeFlags.ObjectType)) { for (const prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { @@ -8178,7 +8178,7 @@ namespace ts { } function isTypeAnyOrAllConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean { - return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); + return isTypeAny(type) || isTypeOfKind(type, kind); } function isNumericLiteralName(name: string) { @@ -9684,7 +9684,7 @@ namespace ts { case SyntaxKind.ComputedPropertyName: const nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, TypeFlags.ESSymbol)) { + if (isTypeOfKind(nameType, TypeFlags.ESSymbol)) { return nameType; } else { @@ -10337,8 +10337,8 @@ namespace ts { const widenedType = getWidenedType(exprType); // Permit 'number[] | "foo"' to be asserted to 'string'. - const bothAreStringLike = someConstituentTypeHasKind(targetType, TypeFlags.StringLike) && - someConstituentTypeHasKind(widenedType, TypeFlags.StringLike); + const bothAreStringLike = maybeTypeOfKind(targetType, TypeFlags.StringLike) && + maybeTypeOfKind(widenedType, TypeFlags.StringLike); if (!bothAreStringLike && !(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } @@ -10593,7 +10593,7 @@ namespace ts { } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && someConstituentTypeHasKind(returnType, TypeFlags.Any | TypeFlags.Void)) { + if (returnType && maybeTypeOfKind(returnType, TypeFlags.Any | TypeFlags.Void)) { return; } @@ -10849,7 +10849,7 @@ namespace ts { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: case SyntaxKind.TildeToken: - if (someConstituentTypeHasKind(operandType, TypeFlags.ESSymbol)) { + if (maybeTypeOfKind(operandType, TypeFlags.ESSymbol)) { error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator)); } return numberType; @@ -10883,14 +10883,14 @@ namespace ts { // Return true if type might be of the given kind. A union or intersection type might be of a given // kind if at least one constituent type is of the given kind. - function someConstituentTypeHasKind(type: Type, kind: TypeFlags): boolean { + function maybeTypeOfKind(type: Type, kind: TypeFlags): boolean { if (type.flags & kind) { return true; } if (type.flags & TypeFlags.UnionOrIntersection) { const types = (type).types; for (const t of types) { - if (someConstituentTypeHasKind(t, kind)) { + if (maybeTypeOfKind(t, kind)) { return true; } } @@ -10901,14 +10901,14 @@ namespace ts { // Return true if type is of the given kind. A union type is of a given kind if all constituent types // are of the given kind. An intersection type is of a given kind if at least one constituent type is // of the given kind. - function allConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean { + function isTypeOfKind(type: Type, kind: TypeFlags): boolean { if (type.flags & kind) { return true; } if (type.flags & TypeFlags.Union) { const types = (type).types; for (const t of types) { - if (!allConstituentTypesHaveKind(t, kind)) { + if (!isTypeOfKind(t, kind)) { return false; } } @@ -10917,7 +10917,7 @@ namespace ts { if (type.flags & TypeFlags.Intersection) { const types = (type).types; for (const t of types) { - if (allConstituentTypesHaveKind(t, kind)) { + if (isTypeOfKind(t, kind)) { return true; } } @@ -10939,7 +10939,7 @@ namespace ts { // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, TypeFlags.Primitive)) { + if (isTypeOfKind(leftType, TypeFlags.Primitive)) { error(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -11154,13 +11154,13 @@ namespace ts { if (rightType.flags & (TypeFlags.Undefined | TypeFlags.Null)) rightType = leftType; let resultType: Type; - if (allConstituentTypesHaveKind(leftType, TypeFlags.NumberLike) && allConstituentTypesHaveKind(rightType, TypeFlags.NumberLike)) { + if (isTypeOfKind(leftType, TypeFlags.NumberLike) && isTypeOfKind(rightType, TypeFlags.NumberLike)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } else { - if (allConstituentTypesHaveKind(leftType, TypeFlags.StringLike) || allConstituentTypesHaveKind(rightType, TypeFlags.StringLike)) { + if (isTypeOfKind(leftType, TypeFlags.StringLike) || isTypeOfKind(rightType, TypeFlags.StringLike)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -11198,7 +11198,7 @@ namespace ts { case SyntaxKind.EqualsEqualsEqualsToken: case SyntaxKind.ExclamationEqualsEqualsToken: // Permit 'number[] | "foo"' to be asserted to 'string'. - if (someConstituentTypeHasKind(leftType, TypeFlags.StringLike) && someConstituentTypeHasKind(rightType, TypeFlags.StringLike)) { + if (maybeTypeOfKind(leftType, TypeFlags.StringLike) && maybeTypeOfKind(rightType, TypeFlags.StringLike)) { return booleanType; } if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { @@ -11223,8 +11223,8 @@ namespace ts { // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { const offendingSymbolOperand = - someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? left : - someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? right : + maybeTypeOfKind(leftType, TypeFlags.ESSymbol) ? left : + maybeTypeOfKind(rightType, TypeFlags.ESSymbol) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator)); @@ -13712,7 +13712,7 @@ namespace ts { let hasDuplicateDefaultClause = false; const expressionType = checkExpression(node.expression); - const expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, TypeFlags.StringLike); + const expressionTypeIsStringLike = maybeTypeOfKind(expressionType, TypeFlags.StringLike); forEach(node.caseBlock.clauses, clause => { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause if (clause.kind === SyntaxKind.DefaultClause && !hasDuplicateDefaultClause) { @@ -13736,7 +13736,7 @@ namespace ts { const expressionTypeIsAssignableToCaseType = // Permit 'number[] | "foo"' to be asserted to 'string'. - (expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, TypeFlags.StringLike)) || + (expressionTypeIsStringLike && maybeTypeOfKind(caseType, TypeFlags.StringLike)) || isTypeAssignableTo(expressionType, caseType); if (!expressionTypeIsAssignableToCaseType) { @@ -15942,22 +15942,22 @@ namespace ts { else if (type.flags & TypeFlags.Any) { return TypeReferenceSerializationKind.ObjectType; } - else if (allConstituentTypesHaveKind(type, TypeFlags.Void)) { + else if (isTypeOfKind(type, TypeFlags.Void)) { return TypeReferenceSerializationKind.VoidType; } - else if (allConstituentTypesHaveKind(type, TypeFlags.Boolean)) { + else if (isTypeOfKind(type, TypeFlags.Boolean)) { return TypeReferenceSerializationKind.BooleanType; } - else if (allConstituentTypesHaveKind(type, TypeFlags.NumberLike)) { + else if (isTypeOfKind(type, TypeFlags.NumberLike)) { return TypeReferenceSerializationKind.NumberLikeType; } - else if (allConstituentTypesHaveKind(type, TypeFlags.StringLike)) { + else if (isTypeOfKind(type, TypeFlags.StringLike)) { return TypeReferenceSerializationKind.StringLikeType; } - else if (allConstituentTypesHaveKind(type, TypeFlags.Tuple)) { + else if (isTypeOfKind(type, TypeFlags.Tuple)) { return TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, TypeFlags.ESSymbol)) { + else if (isTypeOfKind(type, TypeFlags.ESSymbol)) { return TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { From 45409982895306bf78e598604b7bc80ffa6f0ea8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 6 Feb 2016 15:33:56 -0800 Subject: [PATCH 037/102] Adding test --- .../operatorsAndIntersectionTypes.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/cases/conformance/types/intersection/operatorsAndIntersectionTypes.ts diff --git a/tests/cases/conformance/types/intersection/operatorsAndIntersectionTypes.ts b/tests/cases/conformance/types/intersection/operatorsAndIntersectionTypes.ts new file mode 100644 index 00000000000..5689d221840 --- /dev/null +++ b/tests/cases/conformance/types/intersection/operatorsAndIntersectionTypes.ts @@ -0,0 +1,30 @@ +type Guid = string & { $Guid }; // Tagged string type +type SerialNo = number & { $SerialNo }; // Tagged number type + +function createGuid() { + return "21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid; +} + +function createSerialNo() { + return 12345 as SerialNo; +} + +let map1: { [x: string]: number } = {}; +let guid = createGuid(); +map1[guid] = 123; // Can with tagged string + +let map2: { [x: number]: string } = {}; +let serialNo = createSerialNo(); +map2[serialNo] = "hello"; // Can index with tagged number + +const s1 = "{" + guid + "}"; +const s2 = guid.toLowerCase(); +const s3 = guid + guid; +const s4 = guid + serialNo; +const s5 = serialNo.toPrecision(0); +const n1 = serialNo * 3; +const n2 = serialNo + serialNo; +const b1 = guid === ""; +const b2 = guid === guid; +const b3 = serialNo === 0; +const b4 = serialNo === serialNo; From 788ba3c6ac01141e264e4ccbf780ac624a46d928 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 6 Feb 2016 15:34:32 -0800 Subject: [PATCH 038/102] Accepting new baselines --- .../operatorsAndIntersectionTypes.js | 57 ++++++++ .../operatorsAndIntersectionTypes.symbols | 100 +++++++++++++ .../operatorsAndIntersectionTypes.types | 132 ++++++++++++++++++ 3 files changed, 289 insertions(+) create mode 100644 tests/baselines/reference/operatorsAndIntersectionTypes.js create mode 100644 tests/baselines/reference/operatorsAndIntersectionTypes.symbols create mode 100644 tests/baselines/reference/operatorsAndIntersectionTypes.types diff --git a/tests/baselines/reference/operatorsAndIntersectionTypes.js b/tests/baselines/reference/operatorsAndIntersectionTypes.js new file mode 100644 index 00000000000..6f5b3d329d1 --- /dev/null +++ b/tests/baselines/reference/operatorsAndIntersectionTypes.js @@ -0,0 +1,57 @@ +//// [operatorsAndIntersectionTypes.ts] +type Guid = string & { $Guid }; // Tagged string type +type SerialNo = number & { $SerialNo }; // Tagged number type + +function createGuid() { + return "21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid; +} + +function createSerialNo() { + return 12345 as SerialNo; +} + +let map1: { [x: string]: number } = {}; +let guid = createGuid(); +map1[guid] = 123; // Can with tagged string + +let map2: { [x: number]: string } = {}; +let serialNo = createSerialNo(); +map2[serialNo] = "hello"; // Can index with tagged number + +const s1 = "{" + guid + "}"; +const s2 = guid.toLowerCase(); +const s3 = guid + guid; +const s4 = guid + serialNo; +const s5 = serialNo.toPrecision(0); +const n1 = serialNo * 3; +const n2 = serialNo + serialNo; +const b1 = guid === ""; +const b2 = guid === guid; +const b3 = serialNo === 0; +const b4 = serialNo === serialNo; + + +//// [operatorsAndIntersectionTypes.js] +function createGuid() { + return "21EC2020-3AEA-4069-A2DD-08002B30309D"; +} +function createSerialNo() { + return 12345; +} +var map1 = {}; +var guid = createGuid(); +map1[guid] = 123; // Can with tagged string +var map2 = {}; +var serialNo = createSerialNo(); +map2[serialNo] = "hello"; // Can index with tagged number +var s1 = "{" + guid + "}"; +var s2 = guid.toLowerCase(); +var s3 = guid + guid; +var s4 = guid + serialNo; +var s5 = serialNo.toPrecision(0); +var n1 = serialNo * 3; +var n2 = serialNo + serialNo; +var b1 = guid === ""; +var b2 = guid === guid; +var b3 = serialNo === 0; +var b4 = serialNo === serialNo; diff --git a/tests/baselines/reference/operatorsAndIntersectionTypes.symbols b/tests/baselines/reference/operatorsAndIntersectionTypes.symbols new file mode 100644 index 00000000000..7ffc093e4af --- /dev/null +++ b/tests/baselines/reference/operatorsAndIntersectionTypes.symbols @@ -0,0 +1,100 @@ +=== tests/cases/conformance/types/intersection/operatorsAndIntersectionTypes.ts === +type Guid = string & { $Guid }; // Tagged string type +>Guid : Symbol(Guid, Decl(operatorsAndIntersectionTypes.ts, 0, 0)) +>$Guid : Symbol($Guid, Decl(operatorsAndIntersectionTypes.ts, 0, 22)) + +type SerialNo = number & { $SerialNo }; // Tagged number type +>SerialNo : Symbol(SerialNo, Decl(operatorsAndIntersectionTypes.ts, 0, 31)) +>$SerialNo : Symbol($SerialNo, Decl(operatorsAndIntersectionTypes.ts, 1, 26)) + +function createGuid() { +>createGuid : Symbol(createGuid, Decl(operatorsAndIntersectionTypes.ts, 1, 39)) + + return "21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid; +>Guid : Symbol(Guid, Decl(operatorsAndIntersectionTypes.ts, 0, 0)) +} + +function createSerialNo() { +>createSerialNo : Symbol(createSerialNo, Decl(operatorsAndIntersectionTypes.ts, 5, 1)) + + return 12345 as SerialNo; +>SerialNo : Symbol(SerialNo, Decl(operatorsAndIntersectionTypes.ts, 0, 31)) +} + +let map1: { [x: string]: number } = {}; +>map1 : Symbol(map1, Decl(operatorsAndIntersectionTypes.ts, 11, 3)) +>x : Symbol(x, Decl(operatorsAndIntersectionTypes.ts, 11, 13)) + +let guid = createGuid(); +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) +>createGuid : Symbol(createGuid, Decl(operatorsAndIntersectionTypes.ts, 1, 39)) + +map1[guid] = 123; // Can with tagged string +>map1 : Symbol(map1, Decl(operatorsAndIntersectionTypes.ts, 11, 3)) +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) + +let map2: { [x: number]: string } = {}; +>map2 : Symbol(map2, Decl(operatorsAndIntersectionTypes.ts, 15, 3)) +>x : Symbol(x, Decl(operatorsAndIntersectionTypes.ts, 15, 13)) + +let serialNo = createSerialNo(); +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) +>createSerialNo : Symbol(createSerialNo, Decl(operatorsAndIntersectionTypes.ts, 5, 1)) + +map2[serialNo] = "hello"; // Can index with tagged number +>map2 : Symbol(map2, Decl(operatorsAndIntersectionTypes.ts, 15, 3)) +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) + +const s1 = "{" + guid + "}"; +>s1 : Symbol(s1, Decl(operatorsAndIntersectionTypes.ts, 19, 5)) +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) + +const s2 = guid.toLowerCase(); +>s2 : Symbol(s2, Decl(operatorsAndIntersectionTypes.ts, 20, 5)) +>guid.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + +const s3 = guid + guid; +>s3 : Symbol(s3, Decl(operatorsAndIntersectionTypes.ts, 21, 5)) +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) + +const s4 = guid + serialNo; +>s4 : Symbol(s4, Decl(operatorsAndIntersectionTypes.ts, 22, 5)) +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) + +const s5 = serialNo.toPrecision(0); +>s5 : Symbol(s5, Decl(operatorsAndIntersectionTypes.ts, 23, 5)) +>serialNo.toPrecision : Symbol(Number.toPrecision, Decl(lib.d.ts, --, --)) +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) +>toPrecision : Symbol(Number.toPrecision, Decl(lib.d.ts, --, --)) + +const n1 = serialNo * 3; +>n1 : Symbol(n1, Decl(operatorsAndIntersectionTypes.ts, 24, 5)) +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) + +const n2 = serialNo + serialNo; +>n2 : Symbol(n2, Decl(operatorsAndIntersectionTypes.ts, 25, 5)) +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) + +const b1 = guid === ""; +>b1 : Symbol(b1, Decl(operatorsAndIntersectionTypes.ts, 26, 5)) +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) + +const b2 = guid === guid; +>b2 : Symbol(b2, Decl(operatorsAndIntersectionTypes.ts, 27, 5)) +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) +>guid : Symbol(guid, Decl(operatorsAndIntersectionTypes.ts, 12, 3)) + +const b3 = serialNo === 0; +>b3 : Symbol(b3, Decl(operatorsAndIntersectionTypes.ts, 28, 5)) +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) + +const b4 = serialNo === serialNo; +>b4 : Symbol(b4, Decl(operatorsAndIntersectionTypes.ts, 29, 5)) +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) +>serialNo : Symbol(serialNo, Decl(operatorsAndIntersectionTypes.ts, 16, 3)) + diff --git a/tests/baselines/reference/operatorsAndIntersectionTypes.types b/tests/baselines/reference/operatorsAndIntersectionTypes.types new file mode 100644 index 00000000000..70611776fc1 --- /dev/null +++ b/tests/baselines/reference/operatorsAndIntersectionTypes.types @@ -0,0 +1,132 @@ +=== tests/cases/conformance/types/intersection/operatorsAndIntersectionTypes.ts === +type Guid = string & { $Guid }; // Tagged string type +>Guid : string & { $Guid: any; } +>$Guid : any + +type SerialNo = number & { $SerialNo }; // Tagged number type +>SerialNo : number & { $SerialNo: any; } +>$SerialNo : any + +function createGuid() { +>createGuid : () => string & { $Guid: any; } + + return "21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid; +>"21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid : string & { $Guid: any; } +>"21EC2020-3AEA-4069-A2DD-08002B30309D" : string +>Guid : string & { $Guid: any; } +} + +function createSerialNo() { +>createSerialNo : () => number & { $SerialNo: any; } + + return 12345 as SerialNo; +>12345 as SerialNo : number & { $SerialNo: any; } +>12345 : number +>SerialNo : number & { $SerialNo: any; } +} + +let map1: { [x: string]: number } = {}; +>map1 : { [x: string]: number; } +>x : string +>{} : { [x: string]: undefined; } + +let guid = createGuid(); +>guid : string & { $Guid: any; } +>createGuid() : string & { $Guid: any; } +>createGuid : () => string & { $Guid: any; } + +map1[guid] = 123; // Can with tagged string +>map1[guid] = 123 : number +>map1[guid] : number +>map1 : { [x: string]: number; } +>guid : string & { $Guid: any; } +>123 : number + +let map2: { [x: number]: string } = {}; +>map2 : { [x: number]: string; } +>x : number +>{} : { [x: number]: undefined; } + +let serialNo = createSerialNo(); +>serialNo : number & { $SerialNo: any; } +>createSerialNo() : number & { $SerialNo: any; } +>createSerialNo : () => number & { $SerialNo: any; } + +map2[serialNo] = "hello"; // Can index with tagged number +>map2[serialNo] = "hello" : string +>map2[serialNo] : string +>map2 : { [x: number]: string; } +>serialNo : number & { $SerialNo: any; } +>"hello" : string + +const s1 = "{" + guid + "}"; +>s1 : string +>"{" + guid + "}" : string +>"{" + guid : string +>"{" : string +>guid : string & { $Guid: any; } +>"}" : string + +const s2 = guid.toLowerCase(); +>s2 : string +>guid.toLowerCase() : string +>guid.toLowerCase : () => string +>guid : string & { $Guid: any; } +>toLowerCase : () => string + +const s3 = guid + guid; +>s3 : string +>guid + guid : string +>guid : string & { $Guid: any; } +>guid : string & { $Guid: any; } + +const s4 = guid + serialNo; +>s4 : string +>guid + serialNo : string +>guid : string & { $Guid: any; } +>serialNo : number & { $SerialNo: any; } + +const s5 = serialNo.toPrecision(0); +>s5 : string +>serialNo.toPrecision(0) : string +>serialNo.toPrecision : (precision?: number) => string +>serialNo : number & { $SerialNo: any; } +>toPrecision : (precision?: number) => string +>0 : number + +const n1 = serialNo * 3; +>n1 : number +>serialNo * 3 : number +>serialNo : number & { $SerialNo: any; } +>3 : number + +const n2 = serialNo + serialNo; +>n2 : number +>serialNo + serialNo : number +>serialNo : number & { $SerialNo: any; } +>serialNo : number & { $SerialNo: any; } + +const b1 = guid === ""; +>b1 : boolean +>guid === "" : boolean +>guid : string & { $Guid: any; } +>"" : string + +const b2 = guid === guid; +>b2 : boolean +>guid === guid : boolean +>guid : string & { $Guid: any; } +>guid : string & { $Guid: any; } + +const b3 = serialNo === 0; +>b3 : boolean +>serialNo === 0 : boolean +>serialNo : number & { $SerialNo: any; } +>0 : number + +const b4 = serialNo === serialNo; +>b4 : boolean +>serialNo === serialNo : boolean +>serialNo : number & { $SerialNo: any; } +>serialNo : number & { $SerialNo: any; } + From 6b303271f08c78474c4b7838b6288d85fe404ade Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sun, 7 Feb 2016 19:54:38 +0800 Subject: [PATCH 039/102] Go to defininition should not go to named import --- src/services/services.ts | 8 +++++++- tests/cases/fourslash/goToDefinitionImportedNames3.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 6761c487c6c..d291078f7b8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4639,7 +4639,13 @@ namespace ts { // to jump to the implementation directly. if (symbol.flags & SymbolFlags.Alias) { const declaration = symbol.declarations[0]; - if (node.kind === SyntaxKind.Identifier && node.parent === declaration) { + + // We want go to the original declaration if the aliased symbol was declared in the location's parent node. + // Except for cases when the aliased symbol is originating from a named import. + if (node.kind === SyntaxKind.Identifier && + (node.parent === declaration || + (declaration.kind === SyntaxKind.ImportSpecifier && declaration.parent && declaration.parent.kind === SyntaxKind.NamedImports))) { + symbol = typeChecker.getAliasedSymbol(symbol); } } diff --git a/tests/cases/fourslash/goToDefinitionImportedNames3.ts b/tests/cases/fourslash/goToDefinitionImportedNames3.ts index d55137575ef..70fce1749e4 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames3.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames3.ts @@ -31,7 +31,7 @@ goTo.file("e.ts"); goTo.marker('classReference'); goTo.definition(); -verify.caretAtMarker('classAliasDefinition'); +verify.caretAtMarker('classDefinition'); goTo.marker('classAliasDefinition'); goTo.definition(); From 3d8a472527e4f0809c75df42a28d03731dadab35 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sun, 7 Feb 2016 20:09:14 +0800 Subject: [PATCH 040/102] Updated comment --- src/services/services.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index d291078f7b8..7493e894d1c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4640,8 +4640,11 @@ namespace ts { if (symbol.flags & SymbolFlags.Alias) { const declaration = symbol.declarations[0]; - // We want go to the original declaration if the aliased symbol was declared in the location's parent node. - // Except for cases when the aliased symbol is originating from a named import. + // Go to the original declaration for cases: + // + // (1) when the aliased symbol was declared in location(parent). + // (2) when the aliased symbol is originating from a named import. + // if (node.kind === SyntaxKind.Identifier && (node.parent === declaration || (declaration.kind === SyntaxKind.ImportSpecifier && declaration.parent && declaration.parent.kind === SyntaxKind.NamedImports))) { From 43d2054eaca403fb2eebd5fe784b925e75f5d7c6 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sun, 7 Feb 2016 20:10:59 +0800 Subject: [PATCH 041/102] Fixes typo --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 7493e894d1c..211b1358c50 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4642,7 +4642,7 @@ namespace ts { // Go to the original declaration for cases: // - // (1) when the aliased symbol was declared in location(parent). + // (1) when the aliased symbol was declared in the location(parent). // (2) when the aliased symbol is originating from a named import. // if (node.kind === SyntaxKind.Identifier && From bd8aba956f234ee5a365bb14b5da2631007e295b Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Sat, 6 Feb 2016 18:41:23 -0800 Subject: [PATCH 042/102] Fix emitted file extension for JavaScript files with JSX.Preserve (cherry picked from commit af0a0eedd85298d049f89f754364497e36efe671) --- src/compiler/utilities.ts | 18 ++++++++-- .../reference/jsxPreserveWithJsInput.js | 29 +++++++++++++++ .../reference/jsxPreserveWithJsInput.symbols | 27 ++++++++++++++ .../reference/jsxPreserveWithJsInput.types | 35 +++++++++++++++++++ .../cases/compiler/jsxPreserveWithJsInput.ts | 18 ++++++++++ 5 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/jsxPreserveWithJsInput.js create mode 100644 tests/baselines/reference/jsxPreserveWithJsInput.symbols create mode 100644 tests/baselines/reference/jsxPreserveWithJsInput.types create mode 100644 tests/cases/compiler/jsxPreserveWithJsInput.ts diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 09100eb61ed..083e8fc1c4c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2040,8 +2040,22 @@ namespace ts { } function onSingleFileEmit(host: EmitHost, sourceFile: SourceFile) { - const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, - sourceFile.languageVariant === LanguageVariant.JSX && options.jsx === JsxEmit.Preserve ? ".jsx" : ".js"); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + let extension = ".js"; + if (options.jsx === JsxEmit.Preserve) { + if (isSourceFileJavaScript(sourceFile)) { + if (fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === LanguageVariant.JSX) { + // TypeScript source file preserving JSX syntax + extension = ".jsx"; + } + } + const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); const emitFileNames: EmitFileNames = { jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), diff --git a/tests/baselines/reference/jsxPreserveWithJsInput.js b/tests/baselines/reference/jsxPreserveWithJsInput.js new file mode 100644 index 00000000000..2cc59ffa355 --- /dev/null +++ b/tests/baselines/reference/jsxPreserveWithJsInput.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/jsxPreserveWithJsInput.ts] //// + +//// [a.js] + +var elemA = 42; + +//// [b.jsx] +var elemB = {"test"}; + +//// [c.js] +var elemC = {42}; + +//// [d.ts] +var elemD = 42; + +//// [e.tsx] +var elemE = {true}; + + +//// [a.js] +var elemA = 42; +//// [b.jsx] +var elemB = {"test"}; +//// [c.js] +var elemC = {42}; +//// [d.js] +var elemD = 42; +//// [e.jsx] +var elemE = {true}; diff --git a/tests/baselines/reference/jsxPreserveWithJsInput.symbols b/tests/baselines/reference/jsxPreserveWithJsInput.symbols new file mode 100644 index 00000000000..6ad2f614875 --- /dev/null +++ b/tests/baselines/reference/jsxPreserveWithJsInput.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/a.js === + +var elemA = 42; +>elemA : Symbol(elemA, Decl(a.js, 1, 3)) + +=== tests/cases/compiler/b.jsx === +var elemB = {"test"}; +>elemB : Symbol(elemB, Decl(b.jsx, 0, 3)) +>b : Symbol(unknown) +>b : Symbol(unknown) + +=== tests/cases/compiler/c.js === +var elemC = {42}; +>elemC : Symbol(elemC, Decl(c.js, 0, 3)) +>c : Symbol(unknown) +>c : Symbol(unknown) + +=== tests/cases/compiler/d.ts === +var elemD = 42; +>elemD : Symbol(elemD, Decl(d.ts, 0, 3)) + +=== tests/cases/compiler/e.tsx === +var elemE = {true}; +>elemE : Symbol(elemE, Decl(e.tsx, 0, 3)) +>e : Symbol(unknown) +>e : Symbol(unknown) + diff --git a/tests/baselines/reference/jsxPreserveWithJsInput.types b/tests/baselines/reference/jsxPreserveWithJsInput.types new file mode 100644 index 00000000000..7f4ed6daa2b --- /dev/null +++ b/tests/baselines/reference/jsxPreserveWithJsInput.types @@ -0,0 +1,35 @@ +=== tests/cases/compiler/a.js === + +var elemA = 42; +>elemA : number +>42 : number + +=== tests/cases/compiler/b.jsx === +var elemB = {"test"}; +>elemB : any +>{"test"} : any +>b : any +>"test" : string +>b : any + +=== tests/cases/compiler/c.js === +var elemC = {42}; +>elemC : any +>{42} : any +>c : any +>42 : number +>c : any + +=== tests/cases/compiler/d.ts === +var elemD = 42; +>elemD : number +>42 : number + +=== tests/cases/compiler/e.tsx === +var elemE = {true}; +>elemE : any +>{true} : any +>e : any +>true : boolean +>e : any + diff --git a/tests/cases/compiler/jsxPreserveWithJsInput.ts b/tests/cases/compiler/jsxPreserveWithJsInput.ts new file mode 100644 index 00000000000..f229e40a550 --- /dev/null +++ b/tests/cases/compiler/jsxPreserveWithJsInput.ts @@ -0,0 +1,18 @@ +// @outdir: out +// @jsx: preserve +// @allowjs: true + +// @filename: a.js +var elemA = 42; + +// @filename: b.jsx +var elemB = {"test"}; + +// @filename: c.js +var elemC = {42}; + +// @filename: d.ts +var elemD = 42; + +// @filename: e.tsx +var elemE = {true}; From 116bce37ea71a5b4422dbba72454f640b944c4b2 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 8 Feb 2016 10:52:01 -0800 Subject: [PATCH 043/102] Add missing tests from portfix6901 --- ...CallBeforeEmitParameterPropertyDeclaration1.ts | 12 ++++++++++++ ...lBeforeEmitParameterPropertyDeclaration1ES6.ts | 13 +++++++++++++ ...emitSuperCallBeforeEmitPropertyDeclaration1.ts | 15 +++++++++++++++ ...tSuperCallBeforeEmitPropertyDeclaration1ES6.ts | 15 +++++++++++++++ ...DeclarationAndParameterPropertyDeclaration1.ts | 13 +++++++++++++ ...larationAndParameterPropertyDeclaration1ES6.ts | 14 ++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts create mode 100644 tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts create mode 100644 tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts create mode 100644 tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts create mode 100644 tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts create mode 100644 tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts b/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts new file mode 100644 index 00000000000..5172ccfe21f --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts @@ -0,0 +1,12 @@ +class A { + blub = 6; +} + + +class B extends A { + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts b/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts new file mode 100644 index 00000000000..e62f753d725 --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +class A { + blub = 6; +} + + +class B extends A { + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts new file mode 100644 index 00000000000..52d41c3731a --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts @@ -0,0 +1,15 @@ +class A { + blub = 6; +} + + +class B extends A { + + blub = 12; + + constructor() { + "use strict"; + 'someStringForEgngInject'; + super() + } +} \ No newline at end of file diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts new file mode 100644 index 00000000000..f6c7164ae75 --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts @@ -0,0 +1,15 @@ +// @target: ES6 +class A { + blub = 6; +} + + +class B extends A { + + blub = 12; + + constructor() { + 'someStringForEgngInject'; + super() + } +} \ No newline at end of file diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts new file mode 100644 index 00000000000..a2d8bf8473f --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts @@ -0,0 +1,13 @@ +class A { + blub = 6; +} + + +class B extends A { + blah = 2; + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} \ No newline at end of file diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts new file mode 100644 index 00000000000..8bd8420f8f7 --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +class A { + blub = 6; +} + + +class B extends A { + blah = 2; + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} \ No newline at end of file From b104342c63715eb83aeedadbb524393bc6037dcb Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 8 Feb 2016 17:30:26 -0800 Subject: [PATCH 044/102] Add 'wiki' and 'handbook' directories to the docs folder with READMEs. --- doc/handbook/README.md | 4 ++++ doc/wiki/README.md | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 doc/handbook/README.md create mode 100644 doc/wiki/README.md diff --git a/doc/handbook/README.md b/doc/handbook/README.md new file mode 100644 index 00000000000..2d2e0e83a46 --- /dev/null +++ b/doc/handbook/README.md @@ -0,0 +1,4 @@ +# The TypeScript Handbook + +The contents of the TypeScript Handbook can be read from [its GitHub repository](https://github.com/Microsoft/TypeScript-Handbook). +Issues and pull requests should be directed there. \ No newline at end of file diff --git a/doc/wiki/README.md b/doc/wiki/README.md new file mode 100644 index 00000000000..19961197840 --- /dev/null +++ b/doc/wiki/README.md @@ -0,0 +1,6 @@ +# The TypeScript Wiki + +To read the wiki, [visit the wiki on GitHub](https://github.com/Microsoft/TypeScript/wiki). + +To contribute by filing an issue or sending a pull request, [visit the wiki repository](https://github.com/Microsoft/TypeScript-wiki). + From e848e95babd29f9fa42632faa469696899017f7f Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Tue, 9 Feb 2016 18:16:36 +0000 Subject: [PATCH 045/102] spelling fixes for checker.ts, declarationEmitter.ts, types.ts * accessibility * accessor * annotate * anything * apply * assignability * collection * conservatively * constituent * constructor * containing * contextual * contributed * declaration * excessively * exclusion * field * indistinguishable * initializer * intrinsic * knowing * noisiness * occurred * overridden * parameter * perspective * properties * property * prototype * rewritten * specifies * symbolFromSymbolTable --- src/compiler/checker.ts | 84 +++++++++---------- src/compiler/declarationEmitter.ts | 124 ++++++++++++++--------------- src/compiler/types.ts | 18 ++--- 3 files changed, 113 insertions(+), 113 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 63a4185a8bb..01a279c3a4f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -467,10 +467,10 @@ namespace ts { * @return a tuple of two symbols */ function getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): [Symbol, Symbol] { - const constructoDeclaration = parameter.parent; + const constructorDeclaration = parameter.parent; const classDeclaration = parameter.parent.parent; - const parameterSymbol = getSymbol(constructoDeclaration.locals, parameterName, SymbolFlags.Value); + const parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, SymbolFlags.Value); const propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, SymbolFlags.Value); if (parameterSymbol && propertySymbol) { @@ -1460,7 +1460,7 @@ namespace ts { function isAccessible(symbolFromSymbolTable: Symbol, resolvedAliasSymbol?: Symbol) { if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) - // and if symbolfrom symbolTable or alias resolution matches the symbol, + // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible return !forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && canQualifySymbol(symbolFromSymbolTable, meaning); @@ -1531,7 +1531,7 @@ namespace ts { return qualify; } - function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult { + function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult { if (symbol && enclosingDeclaration && !(symbol.flags & SymbolFlags.TypeParameter)) { const initialSymbol = symbol; let meaningToLook = meaning; @@ -1541,7 +1541,7 @@ namespace ts { if (accessibleSymbolChain) { const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { - return { + return { accessibility: SymbolAccessibility.NotAccessible, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, SymbolFlags.Namespace) : undefined, @@ -2140,10 +2140,10 @@ namespace ts { } } - function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) { + function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags) { const targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaration, flags); } } @@ -3421,7 +3421,7 @@ namespace ts { // Returns true if the class or interface member given by the symbol is free of "this" references. The // function may return false for symbols that are actually free of "this" references because it is not // feasible to perform a complete analysis in all cases. In particular, property members with types - // inferred from their initializers and function members with inferred return types are convervatively + // inferred from their initializers and function members with inferred return types are conservatively // assumed not to be free of "this" references. function isIndependentMember(symbol: Symbol): boolean { if (symbol.declarations && symbol.declarations.length === 1) { @@ -5892,7 +5892,7 @@ namespace ts { if (kind === SignatureKind.Construct && sourceSignatures.length && targetSignatures.length && isAbstractConstructorType(source) && !isAbstractConstructorType(target)) { // An abstract constructor type is not assignable to a non-abstract constructor type - // as it would otherwise be possible to new an abstract class. Note that the assignablity + // as it would otherwise be possible to new an abstract class. Note that the assignability // check we perform for an extends clause excludes construct signatures from the target, // so this check never proceeds. if (reportErrors) { @@ -6579,7 +6579,7 @@ namespace ts { } } else if (source.flags & TypeFlags.UnionOrIntersection) { - // Source is a union or intersection type, infer from each consituent type + // Source is a union or intersection type, infer from each constituent type const sourceTypes = (source).types; for (const sourceType of sourceTypes) { inferFromTypes(sourceType, target); @@ -7397,7 +7397,7 @@ namespace ts { if (container.kind === SyntaxKind.FunctionExpression) { if (getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') - const className = (((container.parent as BinaryExpression) // x.protoype.y = f + const className = (((container.parent as BinaryExpression) // x.prototype.y = f .left as PropertyAccessExpression) // x.prototype.y .expression as PropertyAccessExpression) // x.prototype .expression; // x @@ -7920,7 +7920,7 @@ namespace ts { * Otherwise this may not be very useful. * * In cases where you *are* working on this function, you should understand - * when it is appropriate to use 'getContextualType' and 'getApparentTypeOfContetxualType'. + * when it is appropriate to use 'getContextualType' and 'getApparentTypeOfContextualType'. * * - Use 'getContextualType' when you are simply going to propagate the result to the expression. * - Use 'getApparentTypeOfContextualType' when you're going to need the members of the type. @@ -8587,10 +8587,10 @@ namespace ts { } /// e.g. "props" for React.d.ts, - /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), /// or '' if it has 0 properties (which means every - /// non-instrinsic elements' attributes type is the element instance type) + /// non-intrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX const jsxNamespace = getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/undefined); @@ -8598,7 +8598,7 @@ namespace ts { const attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, SymbolFlags.Type); // JSX.ElementAttributesProperty [type] const attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - // The properites of JSX.ElementAttributesProperty + // The properties of JSX.ElementAttributesProperty const attribProperties = attribPropType && getPropertiesOfType(attribPropType); if (attribProperties) { @@ -9429,7 +9429,7 @@ namespace ts { // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. if (excludeArgument) { for (let i = 0; i < argCount; i++) { - // No need to check for omitted args and template expressions, their exlusion value is always undefined + // No need to check for omitted args and template expressions, their exclusion value is always undefined if (excludeArgument[i] === false) { const arg = args[i]; const paramType = getTypeAtPosition(signature, i); @@ -9710,7 +9710,7 @@ namespace ts { */ function getEffectiveDecoratorThirdArgumentType(node: Node) { // The third argument to a decorator is either its `descriptor` for a method decorator - // or its `parameterIndex` for a paramter decorator + // or its `parameterIndex` for a parameter decorator if (node.kind === SyntaxKind.ClassDeclaration) { Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; @@ -10078,7 +10078,7 @@ namespace ts { // We exclude union types because we may have a union of function types that happen to have // no common signatures. if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) { - // The unknownType indicates that an error already occured (and was reported). No + // The unknownType indicates that an error already occurred (and was reported). No // need to report another error in this case. if (funcType !== unknownType && node.typeArguments) { error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -10288,10 +10288,10 @@ namespace ts { const signature = getResolvedSignature(node); if (node.expression.kind === SyntaxKind.SuperKeyword) { - const containgFunction = getContainingFunction(node.expression); + const containingFunction = getContainingFunction(node.expression); - if (containgFunction && containgFunction.kind === SyntaxKind.Constructor) { - getNodeLinks(containgFunction).flags |= NodeCheckFlags.HasSeenSuperCall; + if (containingFunction && containingFunction.kind === SyntaxKind.Constructor) { + getNodeLinks(containingFunction).flags |= NodeCheckFlags.HasSeenSuperCall; } return voidType; } @@ -11812,7 +11812,7 @@ namespace ts { function checkConstructorDeclaration(node: ConstructorDeclaration) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. checkSignatureDeclaration(node); - // Grammar check for checking only related to constructoDeclaration + // Grammar check for checking only related to constructorDeclaration checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); @@ -12324,7 +12324,7 @@ namespace ts { } } - // Spaces for anyting not declared a 'default export'. + // Spaces for anything not declared a 'default export'. const nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; const commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; @@ -12335,7 +12335,7 @@ namespace ts { for (const d of symbol.declarations) { const declarationSpaces = getDeclarationSpaces(d); - // Only error on the declarations that conributed to the intersecting spaces. + // Only error on the declarations that contributed to the intersecting spaces. if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { error(d.name, Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, declarationNameToString(d.name)); } @@ -13551,7 +13551,7 @@ namespace ts { * This function does the following steps: * 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents. * 2. Take the element types of the array constituents. - * 3. Return the union of the element types, and string if there was a string constitutent. + * 3. Return the union of the element types, and string if there was a string constituent. * * For example: * string -> string @@ -13625,7 +13625,7 @@ namespace ts { // TODO: Check that target label is valid } - function isGetAccessorWithAnnotatatedSetAccessor(node: FunctionLikeDeclaration) { + function isGetAccessorWithAnnotatedSetAccessor(node: FunctionLikeDeclaration) { return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor))); } @@ -13661,7 +13661,7 @@ namespace ts { error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || returnType.flags & TypeFlags.PredicateType) { + else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func) || returnType.flags & TypeFlags.PredicateType) { if (isAsyncFunctionLike(func)) { const promisedType = getPromisedType(returnType); const awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -14064,7 +14064,7 @@ namespace ts { Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { - // In order to resolve whether the inherited method was overriden in the base class or not, + // In order to resolve whether the inherited method was overridden in the base class or not, // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { @@ -14966,7 +14966,7 @@ namespace ts { const kind = node.kind; if (cancellationToken) { - // Only bother checking on a few construct kinds. We don't want to be excessivly + // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { case SyntaxKind.ModuleDeclaration: @@ -15747,13 +15747,13 @@ namespace ts { function isSymbolOfDeclarationWithCollidingName(symbol: Symbol): boolean { if (symbol.flags & SymbolFlags.BlockScoped) { const links = getSymbolLinks(symbol); - if (links.isDeclaratonWithCollidingName === undefined) { + if (links.isDeclarationWithCollidingName === undefined) { const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (isStatementWithLocals(container)) { const nodeLinks = getNodeLinks(symbol.valueDeclaration); if (!!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { // redeclaration - always should be renamed - links.isDeclaratonWithCollidingName = true; + links.isDeclarationWithCollidingName = true; } else if (nodeLinks.flags & NodeCheckFlags.CapturedBlockScopedBinding) { // binding is captured in the function @@ -15768,21 +15768,21 @@ namespace ts { // console.log(b()); // should print '100' // OR // - binding is declared inside loop but not in inside initializer of iteration statement or directly inside loop body - // * variables from initializer are passed to rewritted loop body as parameters so they are not captured directly + // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything const isDeclaredInLoop = nodeLinks.flags & NodeCheckFlags.BlockScopedBindingInLoop; const inLoopInitializer = isIterationStatement(container, /*lookInLabeledStatements*/ false); const inLoopBodyBlock = container.kind === SyntaxKind.Block && isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); - links.isDeclaratonWithCollidingName = !isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); + links.isDeclarationWithCollidingName = !isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { - links.isDeclaratonWithCollidingName = false; + links.isDeclarationWithCollidingName = false; } } } - return links.isDeclaratonWithCollidingName; + return links.isDeclarationWithCollidingName; } return false; } @@ -15833,7 +15833,7 @@ namespace ts { if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } - // const enums and modules that contain only const enums are not considered values from the emit perespective + // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true return target !== unknownSymbol && target && @@ -16693,8 +16693,8 @@ namespace ts { const seen: Map = {}; const Property = 1; const GetAccessor = 2; - const SetAccesor = 4; - const GetOrSetAccessor = GetAccessor | SetAccesor; + const SetAccessor = 4; + const GetOrSetAccessor = GetAccessor | SetAccessor; for (const prop of node.properties) { const name = prop.name; @@ -16718,7 +16718,7 @@ namespace ts { } }); - // ECMA-262 11.1.5 Object Initialiser + // ECMA-262 11.1.5 Object Initializer // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and // IsDataDescriptor(propId.descriptor) is true. @@ -16728,7 +16728,7 @@ namespace ts { // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields let currentKind: number; if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) { - // Grammar checking for computedPropertName and shorthandPropertyAssignment + // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, (prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === SyntaxKind.NumericLiteral) { checkGrammarNumericLiteral(name); @@ -16742,7 +16742,7 @@ namespace ts { currentKind = GetAccessor; } else if (prop.kind === SyntaxKind.SetAccessor) { - currentKind = SetAccesor; + currentKind = SetAccessor; } else { Debug.fail("Unexpected syntax kind:" + prop.kind); @@ -17214,7 +17214,7 @@ namespace ts { // We are either parented by another statement, or some sort of block. // If we're in a block, we only want to really report an error once - // to prevent noisyness. So use a bit on the block to indicate if + // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // if (node.parent.kind === SyntaxKind.Block || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 5977c84d7f4..21317fe4918 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -18,7 +18,7 @@ namespace ts { referencePathsOutput: string; } - type GetSymbolAccessibilityDiagnostic = (symbolAccesibilityResult: SymbolAccessiblityResult) => SymbolAccessibilityDiagnostic; + type GetSymbolAccessibilityDiagnostic = (symbolAccessibilityResult: SymbolAccessibilityResult) => SymbolAccessibilityDiagnostic; interface EmitTextWriterWithSymbolWriter extends EmitTextWriter, SymbolWriter { getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic; @@ -252,30 +252,30 @@ namespace ts { setWriter(oldWriter); } - function handleSymbolAccessibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) { - if (symbolAccesibilityResult.accessibility === SymbolAccessibility.Accessible) { + function handleSymbolAccessibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) { + if (symbolAccessibilityResult.accessibility === SymbolAccessibility.Accessible) { // write the aliases - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccessibilityResult.aliasesToMakeVisible); } } else { // Report error reportedDeclarationError = true; - const errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + const errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccessibilityResult); if (errorInfo) { if (errorInfo.typeName) { - emitterDiagnostics.add(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, + emitterDiagnostics.add(createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, getTextOfNodeFromSourceText(currentText, errorInfo.typeName), - symbolAccesibilityResult.errorSymbolName, - symbolAccesibilityResult.errorModuleName)); + symbolAccessibilityResult.errorSymbolName, + symbolAccessibilityResult.errorModuleName)); } else { - emitterDiagnostics.add(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, + emitterDiagnostics.add(createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, - symbolAccesibilityResult.errorSymbolName, - symbolAccesibilityResult.errorModuleName)); + symbolAccessibilityResult.errorSymbolName, + symbolAccessibilityResult.errorModuleName)); } } } @@ -548,7 +548,7 @@ namespace ts { writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + function getDefaultExportAccessibilityDiagnostic(diagnostic: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { return { diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -677,7 +677,7 @@ namespace ts { } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + function getImportEntityNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { return { diagnosticMessage: Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -733,7 +733,7 @@ namespace ts { function emitExternalModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration) { // emitExternalModuleSpecifier is usually called when we emit something in the.d.ts file that will make it an external module (i.e. import/export declarations). // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered - // external modules since they are indistingushable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' + // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== SyntaxKind.ModuleDeclaration; let moduleSpecifier: Node; @@ -850,7 +850,7 @@ namespace ts { writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { return { diagnosticMessage: Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -917,7 +917,7 @@ namespace ts { } } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { // Type parameter constraints are named by user so we should always be able to name it let diagnosticMessage: DiagnosticMessage; switch (node.parent.kind) { @@ -987,7 +987,7 @@ namespace ts { write("null"); } - function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + function getHeritageClauseVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; // Heritage clause is written by user so it can always be named if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { @@ -1104,10 +1104,10 @@ namespace ts { } } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult: SymbolAccessiblityResult) { + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { if (node.kind === SyntaxKind.VariableDeclaration) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; @@ -1116,30 +1116,30 @@ namespace ts { else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & NodeFlags.Static) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { // Interfaces cannot have types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; } } } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: node, @@ -1163,8 +1163,8 @@ namespace ts { } function emitBindingElement(bindingElement: BindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getBindingElementTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + const diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: bindingElement, @@ -1255,17 +1255,17 @@ namespace ts { } } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; if (accessorWithTypeAnnotation.kind === SyntaxKind.SetAccessor) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & NodeFlags.Static) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; } @@ -1278,15 +1278,15 @@ namespace ts { } else { if (accessorWithTypeAnnotation.flags & NodeFlags.Static) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; @@ -1385,26 +1385,26 @@ namespace ts { writeLine(); } - function getReturnTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { + function getReturnTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; switch (node.kind) { case SyntaxKind.ConstructSignature: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; case SyntaxKind.CallSignature: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; case SyntaxKind.IndexSignature: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; @@ -1412,30 +1412,30 @@ namespace ts { case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: if (node.flags & NodeFlags.Static) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; case SyntaxKind.FunctionDeclaration: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -1481,8 +1481,8 @@ namespace ts { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { - const diagnosticMessage: DiagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + const diagnosticMessage: DiagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage, errorNode: node, @@ -1490,53 +1490,53 @@ namespace ts { } : undefined; } - function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult: SymbolAccessiblityResult): DiagnosticMessage { + function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult): DiagnosticMessage { switch (node.parent.kind) { case SyntaxKind.Constructor: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; case SyntaxKind.ConstructSignature: // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; case SyntaxKind.CallSignature: // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: if (node.parent.flags & NodeFlags.Static) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } case SyntaxKind.FunctionDeclaration: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 05b22fd2634..31448c2859c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1559,7 +1559,7 @@ namespace ts { /* @internal */ classifiableNames?: Map; // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined // It is used to resolve module names in the checker. - // Content of this fiels should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead + // Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead /* @internal */ resolvedModules: Map; /* @internal */ imports: LiteralExpression[]; /* @internal */ moduleAugmentations: LiteralExpression[]; @@ -1753,7 +1753,7 @@ namespace ts { buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1846,7 +1846,7 @@ namespace ts { } /* @internal */ - export interface SymbolAccessiblityResult extends SymbolVisibilityResult { + export interface SymbolAccessibilityResult extends SymbolVisibilityResult { errorModuleName?: string; // If the symbol is not visible from module, module's name } @@ -1888,7 +1888,7 @@ namespace ts { writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; + isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult; isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; @@ -2013,7 +2013,7 @@ namespace ts { containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked - isDeclaratonWithCollidingName?: boolean; // True if symbol is block scoped redeclaration + isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // true if module exports some value (not just types) } @@ -2062,7 +2062,7 @@ namespace ts { assignmentChecks?: Map; // Cache of assignment checks hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context importOnRightSide?: Symbol; // for import declarations - import that appear on the right side - jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with + jsxFlags?: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element } @@ -2167,7 +2167,7 @@ namespace ts { // Type references (TypeFlags.Reference). When a class or interface has type parameters or // a "this" type, references to the class or interface are made using type references. The - // typeArguments property specififes the types to substitute for the type parameters of the + // typeArguments property specifies the types to substitute for the type parameters of the // class or interface and optionally includes an extra element that specifies the type to // substitute for "this" in the resulting instantiation. When no extra argument is present, // the type reference itself is substituted for "this". The typeArguments property is undefined @@ -2694,7 +2694,7 @@ namespace ts { /* * CompilerHost must either implement resolveModuleNames (in case if it wants to be completely in charge of * module name resolution) or provide implementation for methods from ModuleResolutionHost (in this case compiler - * will appply built-in module resolution logic and use members of ModuleResolutionHost to ask host specific questions). + * will apply built-in module resolution logic and use members of ModuleResolutionHost to ask host specific questions). * If resolveModuleNames is implemented then implementation for members from ModuleResolutionHost can be just * 'throw new Error("NotImplemented")' */ @@ -2720,7 +2720,7 @@ namespace ts { getGlobalDiagnostics(): Diagnostic[]; // If fileName is provided, gets all the diagnostics associated with that file name. - // Otherwise, returns all the diagnostics (global and file associated) in this colletion. + // Otherwise, returns all the diagnostics (global and file associated) in this collection. getDiagnostics(fileName?: string): Diagnostic[]; // Gets a count of how many times this collection has been modified. This value changes From 0355d1fdc89cf74d9ba68663c165f9f9b1790ba3 Mon Sep 17 00:00:00 2001 From: vladima Date: Wed, 10 Feb 2016 00:20:40 -0800 Subject: [PATCH 046/102] fix source maps for in-browser tests --- Jakefile.js | 75 +++++++++++++++++++++++------------------- src/harness/harness.ts | 2 +- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 7b85aacaa89..84248ca34d1 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -223,51 +223,59 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); * @param prereqs: prerequisite tasks to compiling the file * @param prefixes: a list of files to prepend to the target file * @param useBuiltCompiler: true to use the built compiler, false to use the LKG - * @param noOutFile: true to compile without using --out - * @param generateDeclarations: true to compile using --declaration - * @param outDir: true to compile using --outDir - * @param keepComments: false to compile using --removeComments + * @parap {Object} opts - property bag containing auxiliary options + * @param {boolean} opts.noOutFile: true to compile without using --out + * @param {boolean} opts.generateDeclarations: true to compile using --declaration + * @param {string} opts.outDir: value for '--outDir' command line option + * @param {boolean} opts.keepComments: false to compile using --removeComments + * @param {boolean} opts.preserveConstEnums: true if compiler should keep const enums in code + * @param {boolean} opts.noResolve: true if compiler should not include non-rooted files in compilation + * @param {boolean} opts.stripInternal: true if compiler should remove declarations marked as @internal + * @param {boolean} opts.noMapRoot: true if compiler omit mapRoot option * @param callback: a function to execute after the compilation process ends */ -function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) { +function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) { file(outFile, prereqs, function() { var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; var options = "--noImplicitAny --noEmitOnError --pretty"; - + opts = opts || {}; // Keep comments when specifically requested // or when in debug mode. - if (!(keepComments || useDebugMode)) { + if (!(opts.keepComments || useDebugMode)) { options += " --removeComments"; } - if (generateDeclarations) { + if (opts.generateDeclarations) { options += " --declaration"; } - if (preserveConstEnums || useDebugMode) { + if (opts.preserveConstEnums || useDebugMode) { options += " --preserveConstEnums"; } - if (outDir) { - options += " --outDir " + outDir; + if (opts.outDir) { + options += " --outDir " + opts.outDir; } - if (!noOutFile) { + if (!opts.noOutFile) { options += " --out " + outFile; } else { options += " --module commonjs" } - if(noResolve) { + if(opts.noResolve) { options += " --noResolve"; } if (useDebugMode) { - options += " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile)); + options += " -sourcemap"; + if (!opts.noMapRoot) { + options += " -mapRoot file:///" + path.resolve(path.dirname(outFile)); + } } - if (stripInternal) { + if (opts.stripInternal) { options += " --stripInternal" } @@ -382,13 +390,7 @@ compileFile(/*outfile*/configureNightlyJs, /*prereqs*/ [configureNightlyTs], /*prefixes*/ [], /*useBuiltCompiler*/ false, - /*noOutFile*/ false, - /*generateDeclarations*/ false, - /*outDir*/ undefined, - /*preserveConstEnums*/ undefined, - /*keepComments*/ false, - /*noResolve*/ false, - /*stripInternal*/ false); + { noOutFile: false, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false }); task("setDebugMode", function() { useDebugMode = true; @@ -438,6 +440,7 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename); compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false); var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js"); +var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js"); var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts"); var nodePackageFile = path.join(builtLocalDirectory, "typescript.js"); var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts"); @@ -446,13 +449,7 @@ var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_s compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, - /*noOutFile*/ false, - /*generateDeclarations*/ true, - /*outDir*/ undefined, - /*preserveConstEnums*/ true, - /*keepComments*/ true, - /*noResolve*/ false, - /*stripInternal*/ true, + { noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true }, /*callback*/ function () { jake.cpR(servicesFile, nodePackageFile, {silent: true}); @@ -475,6 +472,16 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents); }); +compileFile(servicesFileInBrowserTest, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), + /*prefixes*/ [copyright], + /*useBuiltCompiler*/ true, + { noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true, noMapRoot: true }, + /*callback*/ function () { + var content = fs.readFileSync(servicesFileInBrowserTest).toString(); + var i = content.lastIndexOf("\n"); + fs.writeFileSync(servicesFileInBrowserTest, content.substring(0, i) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content.substring(i)); + }); + var serverFile = path.join(builtLocalDirectory, "tsserver.js"); compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true); @@ -486,8 +493,7 @@ compileFile( [builtLocalDirectory, copyright].concat(languageServiceLibrarySources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, - /*noOutFile*/ false, - /*generateDeclarations*/ true); + { noOutFile: false, generateDeclarations: true }); // Local target to build the language service server library desc("Builds language service server library"); @@ -720,7 +726,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () { // Browser tests var nodeServerOutFile = 'tests/webTestServer.js' var nodeServerInFile = 'tests/webTestServer.ts' -compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, /*noOutFile*/ true); +compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true }); desc("Runs browserify on run.js to produce a file suitable for running tests in the browser"); task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() { @@ -729,7 +735,7 @@ task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() }, {async: true}); desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]"); -task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function() { +task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() { cleanTestDirs(); host = "node" port = process.env.port || process.env.p || '8888'; @@ -881,7 +887,8 @@ var tslintRulesOutFiles = tslintRules.map(function(p) { desc("Compiles tslint rules to js"); task("build-rules", tslintRulesOutFiles); tslintRulesFiles.forEach(function(ruleFile, i) { - compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, /*noOutFile*/ true, /*generateDeclarations*/ false, path.join(builtLocalDirectory, "tslint")); + compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, + { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint")}); }); function getLinterOptions() { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 848b0d4e063..a21495f27bd 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -746,7 +746,7 @@ namespace Harness { namespace Harness { export const libFolder = "built/local/"; - const tcServicesFileName = ts.combinePaths(libFolder, "typescriptServices.js"); + const tcServicesFileName = ts.combinePaths(libFolder, Utils.getExecutionEnvironment() === Utils.ExecutionEnvironment.Browser ? "typescriptServicesInBrowserTest.js" : "typescriptServices.js"); export const tcServicesFile = IO.readFile(tcServicesFileName); export interface SourceMapEmitterCallback { From 5b1469aece62f30c2c8c0c0341e6c81609aa8b4c Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 10 Feb 2016 10:41:52 -0800 Subject: [PATCH 047/102] Add undefined checks for malformed type tags Fixes #7002 --- src/compiler/checker.ts | 4 ++-- src/harness/harness.ts | 3 +++ tests/baselines/reference/malformedTags.js | 17 +++++++++++++++++ tests/baselines/reference/malformedTags.symbols | 13 +++++++++++++ tests/baselines/reference/malformedTags.types | 13 +++++++++++++ tests/cases/conformance/salsa/malformedTags.ts | 10 ++++++++++ 6 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/malformedTags.js create mode 100644 tests/baselines/reference/malformedTags.symbols create mode 100644 tests/baselines/reference/malformedTags.types create mode 100644 tests/cases/conformance/salsa/malformedTags.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 61fe8f3a794..a3555eca745 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2613,7 +2613,7 @@ namespace ts { function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration): JSDocType { // First, see if this node has an @type annotation on it directly. const typeTag = getJSDocTypeTag(declaration); - if (typeTag) { + if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } @@ -2623,7 +2623,7 @@ namespace ts { // @type annotation might have been on the variable statement, try that instead. const annotation = getJSDocTypeTag(declaration.parent.parent); - if (annotation) { + if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 848b0d4e063..6b9ae6a15db 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -938,6 +938,9 @@ namespace Harness { } } } + else if (name === 'suppressOutputPathCheck') { + options.suppressOutputPathCheck = true; + } else { throw new Error(`Unknown compiler option '${name}'.`); } diff --git a/tests/baselines/reference/malformedTags.js b/tests/baselines/reference/malformedTags.js new file mode 100644 index 00000000000..33b2c1e6f41 --- /dev/null +++ b/tests/baselines/reference/malformedTags.js @@ -0,0 +1,17 @@ +//// [myFile02.js] + +/** + * Checks if `value` is classified as an `Array` object. + * + * @type Function + */ +var isArray = Array.isArray; + + +//// [myFile02.js] +/** + * Checks if `value` is classified as an `Array` object. + * + * @type Function + */ +var isArray = Array.isArray; diff --git a/tests/baselines/reference/malformedTags.symbols b/tests/baselines/reference/malformedTags.symbols new file mode 100644 index 00000000000..df953a82497 --- /dev/null +++ b/tests/baselines/reference/malformedTags.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/salsa/myFile02.js === + +/** + * Checks if `value` is classified as an `Array` object. + * + * @type Function + */ +var isArray = Array.isArray; +>isArray : Symbol(isArray, Decl(myFile02.js, 6, 3)) +>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/malformedTags.types b/tests/baselines/reference/malformedTags.types new file mode 100644 index 00000000000..acf442f7cba --- /dev/null +++ b/tests/baselines/reference/malformedTags.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/salsa/myFile02.js === + +/** + * Checks if `value` is classified as an `Array` object. + * + * @type Function + */ +var isArray = Array.isArray; +>isArray : (arg: any) => arg is any[] +>Array.isArray : (arg: any) => arg is any[] +>Array : ArrayConstructor +>isArray : (arg: any) => arg is any[] + diff --git a/tests/cases/conformance/salsa/malformedTags.ts b/tests/cases/conformance/salsa/malformedTags.ts new file mode 100644 index 00000000000..1128ce73f15 --- /dev/null +++ b/tests/cases/conformance/salsa/malformedTags.ts @@ -0,0 +1,10 @@ +// @allowJS: true +// @suppressOutputPathCheck: true + +// @filename: myFile02.js +/** + * Checks if `value` is classified as an `Array` object. + * + * @type Function + */ +var isArray = Array.isArray; From d64bbc0becc7c4390692f712646ca784a42c2671 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 10 Feb 2016 11:18:02 -0800 Subject: [PATCH 048/102] :heart: linter --- src/harness/harness.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 6b9ae6a15db..230b680eab7 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -938,7 +938,7 @@ namespace Harness { } } } - else if (name === 'suppressOutputPathCheck') { + else if (name === "suppressOutputPathCheck") { options.suppressOutputPathCheck = true; } else { From 8c9baf81c53b44ca7551adf7a64405827708c0eb Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 10 Feb 2016 11:30:21 -0800 Subject: [PATCH 049/102] Check in other places too --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a3555eca745..76323f83e08 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7414,7 +7414,7 @@ namespace ts { function getTypeForThisExpressionFromJSDoc(node: Node) { const typeTag = getJSDocTypeTag(node); - if (typeTag && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) { + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) { const jsDocFunctionType = typeTag.typeExpression.type; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === SyntaxKind.JSDocThisType) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); From 259a89e2cfdfe730c1ad4463970d8f213983cf9e Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 10 Feb 2016 12:51:21 -0800 Subject: [PATCH 050/102] Move suppress option to appropriate place --- src/harness/harness.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 230b680eab7..4d48537a911 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -895,7 +895,8 @@ namespace Harness { { name: "includeBuiltFile", type: "string" }, { name: "fileName", type: "string" }, { name: "libFiles", type: "string" }, - { name: "noErrorTruncation", type: "boolean" } + { name: "noErrorTruncation", type: "boolean" }, + { name: "suppressOutputPathCheck", type: "boolean" } ]; let optionsIndex: ts.Map; @@ -938,9 +939,6 @@ namespace Harness { } } } - else if (name === "suppressOutputPathCheck") { - options.suppressOutputPathCheck = true; - } else { throw new Error(`Unknown compiler option '${name}'.`); } From 196d90a4cee527d0d837b2c37903a8eb14c860e7 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 10 Feb 2016 20:57:53 +0000 Subject: [PATCH 051/102] spelling fixes for src/compiler/binder.ts src/compiler/parser.ts * accidentally * children * exhaustive * initialize * initializer * otherwise * argument * current * delimiter * differently * expression * further * increment * precedence * presence * proceed * signatures * specifier * that * this * unusable --- src/compiler/binder.ts | 20 +++++++++--------- src/compiler/parser.ts | 48 +++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 0e169ca7aca..140902aa4af 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -12,7 +12,7 @@ namespace ts { } const enum Reachability { - Unintialized = 1 << 0, + Uninitialized = 1 << 0, Reachable = 1 << 1, Unreachable = 1 << 2, ReportedUnreachable = 1 << 3 @@ -393,7 +393,7 @@ namespace ts { // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. function bindChildren(node: Node) { - // Before we recurse into a node's chilren, we first save the existing parent, container + // Before we recurse into a node's children, we first save the existing parent, container // and block-container. Then after we pop out of processing the children, we restore // these saved values. const saveParent = parent; @@ -418,7 +418,7 @@ namespace ts { // Finally, if this is a block-container, then we clear out any existing .locals object // it may contain within it. This happens in incremental scenarios. Because we can be // reusing a node from a previous compilation, that node may have had 'locals' created - // for it. We must clear this so we don't accidently move any stale data forward from + // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. const containerFlags = getContainerFlags(node); if (containerFlags & ContainerFlags.IsContainer) { @@ -699,7 +699,7 @@ namespace ts { const hasDefault = forEach(n.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause); - // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case + // post switch state is unreachable if switch is exhaustive (has a default case ) and does not have fallthrough from the last case const postSwitchState = hasDefault && currentReachabilityState !== Reachability.Reachable ? Reachability.Unreachable : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); @@ -766,7 +766,7 @@ namespace ts { case SyntaxKind.Block: // do not treat blocks directly inside a function as a block-scoped-container. - // Locals that reside in this block should go to the function locals. Othewise 'x' + // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following // example: // @@ -956,7 +956,7 @@ namespace ts { const identifier = prop.name; - // ECMA-262 11.1.5 Object Initialiser + // ECMA-262 11.1.5 Object Initializer // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and // IsDataDescriptor(propId.descriptor) is true. @@ -1629,14 +1629,14 @@ namespace ts { if (hasProperty(labelIndexMap, name.text)) { return false; } - labelIndexMap[name.text] = labelStack.push(Reachability.Unintialized) - 1; + labelIndexMap[name.text] = labelStack.push(Reachability.Uninitialized) - 1; return true; } function pushImplicitLabel(): number { initializeReachabilityStateIfNecessary(); - const index = labelStack.push(Reachability.Unintialized) - 1; + const index = labelStack.push(Reachability.Uninitialized) - 1; implicitLabels.push(index); return index; } @@ -1666,7 +1666,7 @@ namespace ts { } function setCurrentStateAtLabel(innerMergedState: Reachability, outerState: Reachability, label: Identifier): void { - if (innerMergedState === Reachability.Unintialized) { + if (innerMergedState === Reachability.Uninitialized) { if (label && !options.allowUnusedLabels) { file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label)); } @@ -1687,7 +1687,7 @@ namespace ts { return false; } const stateAtLabel = labelStack[index]; - labelStack[index] = stateAtLabel === Reachability.Unintialized ? outerState : or(stateAtLabel, outerState); + labelStack[index] = stateAtLabel === Reachability.Uninitialized ? outerState : or(stateAtLabel, outerState); return true; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c80883cf890..66d33f9d7d9 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -577,7 +577,7 @@ namespace ts { scanner.setText(""); scanner.setOnError(undefined); - // Clear any data. We don't want to accidently hold onto it for too long. + // Clear any data. We don't want to accidentally hold onto it for too long. parseDiagnostics = undefined; sourceFile = undefined; identifiers = undefined; @@ -1442,8 +1442,8 @@ namespace ts { // We can only reuse a node if it was parsed under the same strict mode that we're // currently in. i.e. if we originally parsed a node in non-strict mode, but then // the user added 'using strict' at the top of the file, then we can't use that node - // again as the presense of strict mode may cause us to parse the tokens in the file - // differetly. + // again as the presence of strict mode may cause us to parse the tokens in the file + // differently. // // Note: we *can* reuse tokens when the strict mode changes. That's because tokens // are unaffected by strict mode. It's just the parser will decide what to do with it @@ -1456,7 +1456,7 @@ namespace ts { } // Ok, we have a node that looks like it could be reused. Now verify that it is valid - // in the currest list parsing context that we're currently at. + // in the current list parsing context that we're currently at. if (!canReuseNode(node, parsingContext)) { return undefined; } @@ -1719,7 +1719,7 @@ namespace ts { }; // Parses a comma-delimited list of elements - function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimeter?: boolean): NodeArray { + function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray { const saveParsingContext = parsingContext; parsingContext |= 1 << kind; const result = >[]; @@ -1748,7 +1748,7 @@ namespace ts { // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimeter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -2221,7 +2221,7 @@ namespace ts { method.name = name; method.questionToken = questionToken; - // Method signatues don't exist in expression contexts. So they have neither + // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); @@ -2719,7 +2719,7 @@ namespace ts { function isYieldExpression(): boolean { if (token === SyntaxKind.YieldKeyword) { - // If we have a 'yield' keyword, and htis is a context where yield expressions are + // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { return true; @@ -2738,7 +2738,7 @@ namespace ts { // // for now we just check if the next token is an identifier. More heuristics // can be added here later as necessary. We just need to make sure that we - // don't accidently consume something legal. + // don't accidentally consume something legal. return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } @@ -2767,7 +2767,7 @@ namespace ts { } else { // if the next token is not on the same line as yield. or we don't have an '*' or - // the start of an expressin, then this is just a simple "yield" expression. + // the start of an expression, then this is just a simple "yield" expression. return finishNode(node); } } @@ -3060,7 +3060,7 @@ namespace ts { // Check the precedence to see if we should "take" this operator // - For left associative operator (all operator but **), consume the operator, // recursively call the function below, and parse binaryExpression as a rightOperand - // of the caller if the new precendence of the operator is greater then or equal to the current precendence. + // of the caller if the new precedence of the operator is greater then or equal to the current precedence. // For example: // a - b - c; // ^token; leftOperand = b. Return b to the caller as a rightOperand @@ -3069,8 +3069,8 @@ namespace ts { // a - b * c; // ^token; leftOperand = b. Return b * c to the caller as a rightOperand // - For right associative operator (**), consume the operator, recursively call the function - // and parse binaryExpression as a rightOperand of the caller if the new precendence of - // the operator is strictly grater than the current precendence + // and parse binaryExpression as a rightOperand of the caller if the new precedence of + // the operator is strictly grater than the current precedence // For example: // a ** b ** c; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand @@ -3311,7 +3311,7 @@ namespace ts { */ function isIncrementExpression(): boolean { // This function is called inside parseUnaryExpression to decide - // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly + // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token) { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: @@ -3799,7 +3799,7 @@ namespace ts { return undefined; } - // If we have a '<', then only parse this as a arugment list if the type arguments + // If we have a '<', then only parse this as a argument list if the type arguments // are complete and we have an open paren. if we don't, rewind and return nothing. return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments @@ -3996,7 +3996,7 @@ namespace ts { node.multiLine = true; } - node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); parseExpected(SyntaxKind.CloseBraceToken); return finishNode(node); } @@ -4792,8 +4792,8 @@ namespace ts { // off. The grammar would look something like this: // // MemberVariableDeclaration[Yield]: - // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In]; - // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; + // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initializer_opt[In]; + // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initializer_opt[In, ?Yield]; // // The checker may still error in the static case to explicitly disallow the yield expression. property.initializer = modifiers && modifiers.flags & NodeFlags.Static @@ -5394,7 +5394,7 @@ namespace ts { // ImportSpecifier: // BindingIdentifier // IdentifierName as BindingIdentifier - // ExportSpecififer: + // ExportSpecifier: // IdentifierName // IdentifierName as IdentifierName let checkIdentifierIsKeyword = isKeyword(token) && !isIdentifier(); @@ -6238,7 +6238,7 @@ namespace ts { } // Make sure we're not trying to incrementally update a source file more than once. Once - // we do an update the original source file is considered unusbale from that point onwards. + // we do an update the original source file is considered unusable from that point onwards. // // This is because we do incremental parsing in-place. i.e. we take nodes from the old // tree and give them new positions and parents. From that point on, trusting the old @@ -6369,7 +6369,7 @@ namespace ts { // We have an element that intersects the change range in some way. It may have its // start, or its end (or both) in the changed range. We want to adjust any part // that intersects such that the final tree is in a consistent state. i.e. all - // chlidren have spans within the span of their parent, and all siblings are ordered + // children have spans within the span of their parent, and all siblings are ordered // properly. // We may need to update both the 'pos' and the 'end' of the element. @@ -6391,7 +6391,7 @@ namespace ts { // -------------------ZZZ----------------- // // In this case, any element that started in the 'X' range will keep its position. - // However any element htat started after that will have their pos adjusted to be + // However any element that started after that will have their pos adjusted to be // at the end of the new range. i.e. any node that started in the 'Y' range will // be adjusted to have their start at the end of the 'Z' range. // @@ -6416,7 +6416,7 @@ namespace ts { // -------------------ZZZ----------------- // // In this case, any element that ended in the 'X' range will keep its position. - // However any element htat ended after that will have their pos adjusted to be + // However any element that ended after that will have their pos adjusted to be // at the end of the new range. i.e. any node that ended in the 'Y' range will // be adjusted to have their end at the end of the 'Z' range. if (element.end >= changeRangeOldEnd) { @@ -6746,7 +6746,7 @@ namespace ts { // Position was within this node. Keep searching deeper to find the node. forEachChild(node, visitNode, visitArray); - // don't procede any futher in the search. + // don't proceed any further in the search. return true; } From 5b7b57626c51932ef738f7c7425925d436779599 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 10 Feb 2016 13:58:31 -0800 Subject: [PATCH 052/102] split declaration and initialization of writer variable --- src/compiler/declarationEmitter.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 21317fe4918..d8bdd2fb52f 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -51,7 +51,9 @@ namespace ts { let decreaseIndent: () => void; let writeTextOfNode: (text: string, node: Node) => void; - let writer = createAndSetNewTextWriterWithSymbolWriter(); + let writer: EmitTextWriterWithSymbolWriter; + + createAndSetNewTextWriterWithSymbolWriter(); let enclosingDeclaration: Node; let resultHasExternalModuleIndicator: boolean; @@ -174,7 +176,7 @@ namespace ts { } } - function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter { + function createAndSetNewTextWriterWithSymbolWriter(): void { const writer = createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; @@ -186,7 +188,6 @@ namespace ts { writer.writeParameter = writer.write; writer.writeSymbol = writer.write; setWriter(writer); - return writer; } function setWriter(newWriter: EmitTextWriterWithSymbolWriter) { From 284b26f49fa59b2eb349303704e35b4109bccff9 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Thu, 11 Feb 2016 16:56:45 +0000 Subject: [PATCH 053/102] spelling fixes for src/compiler * after * aggressive * appear * asterisks * candidate * conflict * directory * dollar * ellipsis * exports * failures * folder * followed * highlight * inferred * location * occurred * output * propagated * push * rather * remaining * search * stabilized * substitution * successful * even though * will * with --- src/compiler/core.ts | 4 ++-- src/compiler/emitter.ts | 20 ++++++++++---------- src/compiler/program.ts | 18 +++++++++--------- src/compiler/scanner.ts | 4 ++-- src/compiler/sys.ts | 2 +- src/compiler/tsc.ts | 8 ++++---- src/compiler/utilities.ts | 12 ++++++------ 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 21536da36ff..702ded96a3f 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -667,7 +667,7 @@ namespace ts { } function getNormalizedPathComponentsOfUrl(url: string) { - // Get root length of http://www.website.com/folder1/foler2/ + // Get root length of http://www.website.com/folder1/folder2/ // In this example the root is: http://www.website.com/ // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] @@ -695,7 +695,7 @@ namespace ts { const indexOfNextSlash = url.indexOf(directorySeparator, rootLength); if (indexOfNextSlash !== -1) { // Found the "/" after the website.com so the root is length of http://www.website.com/ - // and get components afetr the root normally like any other folder components + // and get components after the root normally like any other folder components rootLength = indexOfNextSlash + 1; return normalizedPathComponents(url, rootLength); } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 68f5963157e..f08082d72c8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -407,14 +407,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge interface ConvertedLoopState { /* - * set of labels that occured inside the converted loop + * set of labels that occurred inside the converted loop * used to determine if labeled jump can be emitted as is or it should be dispatched to calling code */ labels?: Map; /* * collection of labeled jumps that transfer control outside the converted loop. * maps store association 'label -> labelMarker' where - * - label - value of label as it apprear in code + * - label - value of label as it appear in code * - label marker - return value that should be interpreted by calling code as 'jump to