From fe0e80974223f33baa3afa6351becbcb5aa43298 Mon Sep 17 00:00:00 2001 From: Alexader Date: Wed, 9 May 2018 12:17:19 +0300 Subject: [PATCH 001/130] Fix #23180 - Generating source maps with relative path in sourceRoot option produces maps with absolute file paths --- src/compiler/commandLineParser.ts | 2 -- tests/baselines/reference/commonSourceDirectory.js | 2 +- tests/baselines/reference/commonSourceDirectory.js.map | 2 +- .../reference/commonSourceDirectory.sourcemap.txt | 8 ++++---- tests/baselines/reference/commonSourceDirectory_dts.js | 2 +- .../baselines/reference/commonSourceDirectory_dts.js.map | 2 +- .../reference/commonSourceDirectory_dts.sourcemap.txt | 8 ++++---- .../tsConfig/Default initialized TSConfig/tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../Initialized TSConfig with files options/tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- 16 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f648bddefe9..395fe633a03 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -443,7 +443,6 @@ namespace ts { { name: "sourceRoot", type: "string", - isFilePath: true, paramType: Diagnostics.LOCATION, category: Diagnostics.Source_Map_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, @@ -451,7 +450,6 @@ namespace ts { { name: "mapRoot", type: "string", - isFilePath: true, paramType: Diagnostics.LOCATION, category: Diagnostics.Source_Map_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, diff --git a/tests/baselines/reference/commonSourceDirectory.js b/tests/baselines/reference/commonSourceDirectory.js index ca705a5b34e..44991d1b84e 100644 --- a/tests/baselines/reference/commonSourceDirectory.js +++ b/tests/baselines/reference/commonSourceDirectory.js @@ -24,7 +24,7 @@ exports.__esModule = true; var foo_1 = require("foo"); var bar_1 = require("bar"); foo_1.x + bar_1.y; -//# sourceMappingURL=/app/myMapRoot/index.js.map +//# sourceMappingURL=../myMapRoot/index.js.map //// [/app/bin/index.d.ts] /// diff --git a/tests/baselines/reference/commonSourceDirectory.js.map b/tests/baselines/reference/commonSourceDirectory.js.map index fd88719859b..737c1dc3df1 100644 --- a/tests/baselines/reference/commonSourceDirectory.js.map +++ b/tests/baselines/reference/commonSourceDirectory.js.map @@ -1,2 +1,2 @@ //// [/app/bin/index.js.map] -{"version":3,"file":"index.js","sourceRoot":"/app/mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,yCAAyC;AACzC,2BAAwB;AACxB,2BAAwB;AACxB,OAAC,GAAG,OAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,yCAAyC;AACzC,2BAAwB;AACxB,2BAAwB;AACxB,OAAC,GAAG,OAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/commonSourceDirectory.sourcemap.txt b/tests/baselines/reference/commonSourceDirectory.sourcemap.txt index c880d2d0059..567e435ce55 100644 --- a/tests/baselines/reference/commonSourceDirectory.sourcemap.txt +++ b/tests/baselines/reference/commonSourceDirectory.sourcemap.txt @@ -1,7 +1,7 @@ =================================================================== JsFile: index.js -mapUrl: /app/myMapRoot/index.js.map -sourceRoot: /app/mySourceRoot/ +mapUrl: ../myMapRoot/index.js.map +sourceRoot: mySourceRoot/ sources: index.ts =================================================================== ------------------------------------------------------------------- @@ -43,7 +43,7 @@ sourceFile:index.ts 3 > ^^^ 4 > ^^^^^^^ 5 > ^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >x @@ -56,4 +56,4 @@ sourceFile:index.ts 4 >Emitted(6, 18) Source(4, 6) + SourceIndex(0) 5 >Emitted(6, 19) Source(4, 7) + SourceIndex(0) --- ->>>//# sourceMappingURL=/app/myMapRoot/index.js.map \ No newline at end of file +>>>//# sourceMappingURL=../myMapRoot/index.js.map \ No newline at end of file diff --git a/tests/baselines/reference/commonSourceDirectory_dts.js b/tests/baselines/reference/commonSourceDirectory_dts.js index 249edeceddd..1009ff9475b 100644 --- a/tests/baselines/reference/commonSourceDirectory_dts.js +++ b/tests/baselines/reference/commonSourceDirectory_dts.js @@ -15,7 +15,7 @@ export const x = y; exports.__esModule = true; /// exports.x = y; -//# sourceMappingURL=/app/myMapRoot/index.js.map +//# sourceMappingURL=../src/myMapRoot/index.js.map //// [/app/bin/index.d.ts] /// diff --git a/tests/baselines/reference/commonSourceDirectory_dts.js.map b/tests/baselines/reference/commonSourceDirectory_dts.js.map index 552da577884..2950d165917 100644 --- a/tests/baselines/reference/commonSourceDirectory_dts.js.map +++ b/tests/baselines/reference/commonSourceDirectory_dts.js.map @@ -1,2 +1,2 @@ //// [/app/bin/index.js.map] -{"version":3,"file":"index.js","sourceRoot":"/app/mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,wCAAwC;AAC3B,QAAA,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,wCAAwC;AAC3B,QAAA,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt b/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt index 925a3d30ed4..fb2ef3596c6 100644 --- a/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt +++ b/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt @@ -1,7 +1,7 @@ =================================================================== JsFile: index.js -mapUrl: /app/myMapRoot/index.js.map -sourceRoot: /app/mySourceRoot/ +mapUrl: ../src/myMapRoot/index.js.map +sourceRoot: mySourceRoot/ sources: index.ts =================================================================== ------------------------------------------------------------------- @@ -25,7 +25,7 @@ sourceFile:index.ts 4 > ^^^ 5 > ^ 6 > ^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >export const 2 > @@ -40,4 +40,4 @@ sourceFile:index.ts 5 >Emitted(4, 14) Source(2, 19) + SourceIndex(0) 6 >Emitted(4, 15) Source(2, 20) + SourceIndex(0) --- ->>>//# sourceMappingURL=/app/myMapRoot/index.js.map \ No newline at end of file +>>>//# sourceMappingURL=../src/myMapRoot/index.js.map \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 0b72c3fd8a7..261cdca7011 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json index 4d5c6053bcc..d3a9f8e9f47 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index f84c7f3abf3..8484e61bcfa 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index b65582c7841..35aa1cf7eab 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 86d25e2362a..fbc441b823c 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index b623b1198c2..f758c1f6c20 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 0b72c3fd8a7..261cdca7011 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index ea9df560138..cdb52963ccb 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index bab4947a8e5..fd6419e1e35 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ From c88c129567a7a98918a3500cd678a1d0fceba11c Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 11 May 2018 14:03:57 -0700 Subject: [PATCH 002/130] "gulp" -> "jake" On branch `release-2.8`, `gulp` produces a build error. In practice, `jake` is our supported build tool. --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3200498b0cf..68b589efcce 100644 --- a/README.md +++ b/README.md @@ -61,29 +61,29 @@ Change to the TypeScript directory: cd TypeScript ``` -Install Gulp tools and dev dependencies: +Install Jake tools and dev dependencies: ```bash -npm install -g gulp +npm install -g jake npm install ``` Use one of the following to build and test: ``` -gulp local # Build the compiler into built/local -gulp clean # Delete the built compiler -gulp LKG # Replace the last known good with the built one. +jake local # Build the compiler into built/local +jake clean # Delete the built compiler +jake LKG # Replace the last known good with the built one. # Bootstrapping step to be executed when the built compiler reaches a stable state. -gulp tests # Build the test infrastructure using the built compiler. -gulp runtests # Run tests using the built compiler and test infrastructure. +jake tests # Build the test infrastructure using the built compiler. +jake runtests # Run tests using the built compiler and test infrastructure. # You can override the host or specify a test for this command. # Use host= or tests=. -gulp runtests-browser # Runs the tests using the built run.js file. Syntax is gulp runtests. Optional +jake runtests-browser # Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]'. -gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests. -gulp lint # Runs tslint on the TypeScript source. -gulp help # List the above commands. +jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests. +jake lint # Runs tslint on the TypeScript source. +jake help # List the above commands. ``` From 5a69d9c2550a3bdc8f7b92b688388c5a5cce80d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Mon, 16 Apr 2018 14:31:37 +0800 Subject: [PATCH 003/130] add support for add or remove braces to arrow function --- src/compiler/diagnosticMessages.json | 12 +++ src/harness/tsconfig.json | 1 + src/server/tsconfig.json | 1 + src/server/tsconfig.library.json | 1 + .../refactors/convertArrowFunction.ts | 90 +++++++++++++++++++ src/services/tsconfig.json | 1 + .../refactorAddBracesToArrowFunction1.ts | 11 +++ .../refactorAddBracesToArrowFunction2.ts | 11 +++ .../refactorAddBracesToArrowFunction3.ts | 11 +++ .../refactorAddBracesToArrowFunction4.ts | 11 +++ .../refactorAddBracesToArrowFunction5.ts | 11 +++ .../refactorAddBracesToArrowFunction6.ts | 11 +++ .../refactorAddBracesToArrowFunction7.ts | 6 ++ .../refactorAddBracesToArrowFunction8.ts | 9 ++ 14 files changed, 187 insertions(+) create mode 100644 src/services/refactors/convertArrowFunction.ts create mode 100644 tests/cases/fourslash/refactorAddBracesToArrowFunction1.ts create mode 100644 tests/cases/fourslash/refactorAddBracesToArrowFunction2.ts create mode 100644 tests/cases/fourslash/refactorAddBracesToArrowFunction3.ts create mode 100644 tests/cases/fourslash/refactorAddBracesToArrowFunction4.ts create mode 100644 tests/cases/fourslash/refactorAddBracesToArrowFunction5.ts create mode 100644 tests/cases/fourslash/refactorAddBracesToArrowFunction6.ts create mode 100644 tests/cases/fourslash/refactorAddBracesToArrowFunction7.ts create mode 100644 tests/cases/fourslash/refactorAddBracesToArrowFunction8.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 59007e610b4..6660b29fd65 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4280,5 +4280,17 @@ "Remove all unused labels": { "category": "Message", "code": 95054 + }, + "Convert arrow function": { + "category": "Message", + "code": 95055 + }, + "Add braces to arrow function": { + "category": "Message", + "code": 95056 + }, + "Remove braces from arrow function": { + "category": "Message", + "code": 95057 } } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 359701a02cb..4749520822e 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -121,6 +121,7 @@ "../services/refactors/extractSymbol.ts", "../services/refactors/generateGetAccessorAndSetAccessor.ts", "../services/refactors/moveToNewFile.ts", + "../services/refactors/convertArrowFunction.ts", "../services/sourcemaps.ts", "../services/services.ts", "../services/breakpoints.ts", diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 8ae6974baf0..7d81e068648 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -117,6 +117,7 @@ "../services/refactors/extractSymbol.ts", "../services/refactors/generateGetAccessorAndSetAccessor.ts", "../services/refactors/moveToNewFile.ts", + "../services/refactors/convertArrowFunction.ts", "../services/sourcemaps.ts", "../services/services.ts", "../services/breakpoints.ts", diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 922af11e879..df72b37e530 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -123,6 +123,7 @@ "../services/refactors/extractSymbol.ts", "../services/refactors/generateGetAccessorAndSetAccessor.ts", "../services/refactors/moveToNewFile.ts", + "../services/refactors/convertArrowFunction.ts", "../services/sourcemaps.ts", "../services/services.ts", "../services/breakpoints.ts", diff --git a/src/services/refactors/convertArrowFunction.ts b/src/services/refactors/convertArrowFunction.ts new file mode 100644 index 00000000000..af1d232ad3e --- /dev/null +++ b/src/services/refactors/convertArrowFunction.ts @@ -0,0 +1,90 @@ +/* @internal */ +namespace ts.refactor.convertArrowFunction { + const refactorName = "Convert arrow function"; + const refactorDescription = Diagnostics.Convert_arrow_function.message; + const addBracesActionName = "Add braces to arrow function"; + const removeBracesActionName = "Remove braces from arrow function"; + const addBracesActionDescription = Diagnostics.Add_braces_to_arrow_function.message; + const removeBracesActionDescription = Diagnostics.Remove_braces_from_arrow_function.message; + registerRefactor(refactorName, { getEditsForAction, getAvailableActions }); + + interface Info { + container: ArrowFunction; + expression: Expression; + addBraces: boolean; + } + + function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined { + const { file, startPosition } = context; + const info = getConvertibleArrowFunctionAtPosition(file, startPosition); + if (!info) return undefined; + + const actions: RefactorActionInfo[] = [ + info.addBraces ? + { + name: addBracesActionName, + description: addBracesActionDescription + } : { + name: removeBracesActionName, + description: removeBracesActionDescription + } + ]; + + return [{ + name: refactorName, + description: refactorDescription, + actions + }]; + } + + function getEditsForAction(context: RefactorContext, _actionName: string): RefactorEditInfo | undefined { + const { file, startPosition } = context; + const info = getConvertibleArrowFunctionAtPosition(file, startPosition); + if (!info) return undefined; + + const { addBraces, expression, container } = info; + const changeTracker = textChanges.ChangeTracker.fromContext(context); + updateBraces(changeTracker, file, container, expression, addBraces); + + return { + renameFilename: undefined, + renameLocation: undefined, + edits: changeTracker.getChanges() + }; + } + + function updateBraces(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, expression: Expression, addBraces: boolean) { + const body = addBraces ? createBlock([createReturn(expression)]) : expression; + + const arrowFunction = updateArrowFunction( + container, + container.modifiers, + container.typeParameters, + container.parameters, + container.type, + body); + changeTracker.replaceNode(file, container, arrowFunction); + } + + function getConvertibleArrowFunctionAtPosition(file: SourceFile, startPosition: number): Info | undefined { + const node = getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + const container = getContainingFunction(node); + if (!container || !isArrowFunction(container)) return undefined; + + if (isExpression(container.body)) { + return { + container, + addBraces: true, + expression: container.body + }; + } + else if (container.body.statements.length === 1 && isReturnStatement(first(container.body.statements))) { + return { + container, + addBraces: false, + expression: (first(container.body.statements)).expression + }; + } + return undefined; + } +} diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 7e1ccc9c3af..f425c569e31 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -114,6 +114,7 @@ "refactors/extractSymbol.ts", "refactors/generateGetAccessorAndSetAccessor.ts", "refactors/moveToNewFile.ts", + "refactors/convertArrowFunction.ts", "sourcemaps.ts", "services.ts", "breakpoints.ts", diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction1.ts b/tests/cases/fourslash/refactorAddBracesToArrowFunction1.ts new file mode 100644 index 00000000000..fde5a54656e --- /dev/null +++ b/tests/cases/fourslash/refactorAddBracesToArrowFunction1.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => a + 1; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert arrow function", + actionName: "Add braces to arrow function", + actionDescription: "Add braces to arrow function", + newContent: `const foo = a => { return a + 1; };`, +}); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction2.ts b/tests/cases/fourslash/refactorAddBracesToArrowFunction2.ts new file mode 100644 index 00000000000..30f4de0e9a7 --- /dev/null +++ b/tests/cases/fourslash/refactorAddBracesToArrowFunction2.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => ({ a: 1 }); + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert arrow function", + actionName: "Add braces to arrow function", + actionDescription: "Add braces to arrow function", + newContent: `const foo = a => { return ({ a: 1 }); };`, +}); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction3.ts b/tests/cases/fourslash/refactorAddBracesToArrowFunction3.ts new file mode 100644 index 00000000000..cd2d773449e --- /dev/null +++ b/tests/cases/fourslash/refactorAddBracesToArrowFunction3.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => 1; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert arrow function", + actionName: "Add braces to arrow function", + actionDescription: "Add braces to arrow function", + newContent: `const foo = a => { return 1; };`, +}); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction4.ts b/tests/cases/fourslash/refactorAddBracesToArrowFunction4.ts new file mode 100644 index 00000000000..f113d63add4 --- /dev/null +++ b/tests/cases/fourslash/refactorAddBracesToArrowFunction4.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return a + 1; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => a + 1;`, +}); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction5.ts b/tests/cases/fourslash/refactorAddBracesToArrowFunction5.ts new file mode 100644 index 00000000000..bc0cdfd6484 --- /dev/null +++ b/tests/cases/fourslash/refactorAddBracesToArrowFunction5.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return { a: 1 }; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => ({ a: 1 });`, +}); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction6.ts b/tests/cases/fourslash/refactorAddBracesToArrowFunction6.ts new file mode 100644 index 00000000000..999fba05193 --- /dev/null +++ b/tests/cases/fourslash/refactorAddBracesToArrowFunction6.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return 1; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => 1;`, +}); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction7.ts b/tests/cases/fourslash/refactorAddBracesToArrowFunction7.ts new file mode 100644 index 00000000000..7f7a5207515 --- /dev/null +++ b/tests/cases/fourslash/refactorAddBracesToArrowFunction7.ts @@ -0,0 +1,6 @@ +/// + +//// const foo = /*a*/a/*b*/ => { }; + +goTo.select("a", "b"); +verify.not.refactorAvailable("Convert arrow function"); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction8.ts b/tests/cases/fourslash/refactorAddBracesToArrowFunction8.ts new file mode 100644 index 00000000000..1c7f0bd954b --- /dev/null +++ b/tests/cases/fourslash/refactorAddBracesToArrowFunction8.ts @@ -0,0 +1,9 @@ +/// + +//// const foo = /*a*/a/*b*/ => { +//// const b = 1; +//// return a + b; +//// }; + +goTo.select("a", "b"); +verify.not.refactorAvailable("Convert arrow function"); From 32be0c70993dbf36de3cb6166f3ed724c345fa4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Tue, 17 Apr 2018 10:33:21 +0800 Subject: [PATCH 004/130] add tests and fix --- src/compiler/diagnosticMessages.json | 2 +- src/harness/tsconfig.json | 2 +- src/server/tsconfig.json | 2 +- src/server/tsconfig.library.json | 2 +- ...ts => addOrRemoveBracesToArrowFunction.ts} | 69 ++++++++++++------- src/services/tsconfig.json | 2 +- .../refactorAddBracesToArrowFunction7.ts | 6 -- ...actorAddOrRemoveBracesToArrowFunction1.ts} | 2 +- ...actorAddOrRemoveBracesToArrowFunction10.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction11.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction12.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction13.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction14.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction15.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction16.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction17.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction18.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction19.ts | 11 +++ ...actorAddOrRemoveBracesToArrowFunction2.ts} | 2 +- ...actorAddOrRemoveBracesToArrowFunction3.ts} | 2 +- ...actorAddOrRemoveBracesToArrowFunction4.ts} | 4 +- ...actorAddOrRemoveBracesToArrowFunction5.ts} | 2 +- ...actorAddOrRemoveBracesToArrowFunction6.ts} | 2 +- ...actorAddOrRemoveBracesToArrowFunction8.ts} | 2 +- ...factorAddOrRemoveBracesToArrowFunction9.ts | 11 +++ 25 files changed, 178 insertions(+), 44 deletions(-) rename src/services/refactors/{convertArrowFunction.ts => addOrRemoveBracesToArrowFunction.ts} (53%) delete mode 100644 tests/cases/fourslash/refactorAddBracesToArrowFunction7.ts rename tests/cases/fourslash/{refactorAddBracesToArrowFunction1.ts => refactorAddOrRemoveBracesToArrowFunction1.ts} (81%) create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction10.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction11.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction12.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction13.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction14.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction15.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction16.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction17.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction18.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction19.ts rename tests/cases/fourslash/{refactorAddBracesToArrowFunction2.ts => refactorAddOrRemoveBracesToArrowFunction2.ts} (82%) rename tests/cases/fourslash/{refactorAddBracesToArrowFunction3.ts => refactorAddOrRemoveBracesToArrowFunction3.ts} (81%) rename tests/cases/fourslash/{refactorAddBracesToArrowFunction4.ts => refactorAddOrRemoveBracesToArrowFunction4.ts} (70%) rename tests/cases/fourslash/{refactorAddBracesToArrowFunction5.ts => refactorAddOrRemoveBracesToArrowFunction5.ts} (82%) rename tests/cases/fourslash/{refactorAddBracesToArrowFunction6.ts => refactorAddOrRemoveBracesToArrowFunction6.ts} (82%) rename tests/cases/fourslash/{refactorAddBracesToArrowFunction8.ts => refactorAddOrRemoveBracesToArrowFunction8.ts} (66%) create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6660b29fd65..b5cb450bfec 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4281,7 +4281,7 @@ "category": "Message", "code": 95054 }, - "Convert arrow function": { + "Add or remove braces in an arrow function": { "category": "Message", "code": 95055 }, diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 4749520822e..22b7f496704 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -121,7 +121,7 @@ "../services/refactors/extractSymbol.ts", "../services/refactors/generateGetAccessorAndSetAccessor.ts", "../services/refactors/moveToNewFile.ts", - "../services/refactors/convertArrowFunction.ts", + "../services/refactors/addOrRemoveBracesToArrowFunction.ts", "../services/sourcemaps.ts", "../services/services.ts", "../services/breakpoints.ts", diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 7d81e068648..6c5144093ae 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -117,7 +117,7 @@ "../services/refactors/extractSymbol.ts", "../services/refactors/generateGetAccessorAndSetAccessor.ts", "../services/refactors/moveToNewFile.ts", - "../services/refactors/convertArrowFunction.ts", + "../services/refactors/addOrRemoveBracesToArrowFunction.ts", "../services/sourcemaps.ts", "../services/services.ts", "../services/breakpoints.ts", diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index df72b37e530..59ff8cc9e83 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -123,7 +123,7 @@ "../services/refactors/extractSymbol.ts", "../services/refactors/generateGetAccessorAndSetAccessor.ts", "../services/refactors/moveToNewFile.ts", - "../services/refactors/convertArrowFunction.ts", + "../services/refactors/addOrRemoveBracesToArrowFunction.ts", "../services/sourcemaps.ts", "../services/services.ts", "../services/breakpoints.ts", diff --git a/src/services/refactors/convertArrowFunction.ts b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts similarity index 53% rename from src/services/refactors/convertArrowFunction.ts rename to src/services/refactors/addOrRemoveBracesToArrowFunction.ts index af1d232ad3e..df7cacadf3f 100644 --- a/src/services/refactors/convertArrowFunction.ts +++ b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts @@ -1,7 +1,7 @@ /* @internal */ -namespace ts.refactor.convertArrowFunction { - const refactorName = "Convert arrow function"; - const refactorDescription = Diagnostics.Convert_arrow_function.message; +namespace ts.refactor.addOrRemoveBracesToArrowFunction { + const refactorName = "Add or remove braces in an arrow function"; + const refactorDescription = Diagnostics.Add_or_remove_braces_in_an_arrow_function.message; const addBracesActionName = "Add braces to arrow function"; const removeBracesActionName = "Remove braces from arrow function"; const addBracesActionDescription = Diagnostics.Add_braces_to_arrow_function.message; @@ -19,21 +19,19 @@ namespace ts.refactor.convertArrowFunction { const info = getConvertibleArrowFunctionAtPosition(file, startPosition); if (!info) return undefined; - const actions: RefactorActionInfo[] = [ - info.addBraces ? - { - name: addBracesActionName, - description: addBracesActionDescription - } : { - name: removeBracesActionName, - description: removeBracesActionDescription - } - ]; - return [{ name: refactorName, description: refactorDescription, - actions + actions: [ + info.addBraces ? + { + name: addBracesActionName, + description: addBracesActionDescription + } : { + name: removeBracesActionName, + description: removeBracesActionDescription + } + ] }]; } @@ -42,9 +40,18 @@ namespace ts.refactor.convertArrowFunction { const info = getConvertibleArrowFunctionAtPosition(file, startPosition); if (!info) return undefined; - const { addBraces, expression, container } = info; + const { expression, container } = info; const changeTracker = textChanges.ChangeTracker.fromContext(context); - updateBraces(changeTracker, file, container, expression, addBraces); + + if (_actionName === addBracesActionName) { + addBraces(changeTracker, file, container, expression); + } + else if (_actionName === removeBracesActionName) { + removeBraces(changeTracker, file, container, expression); + } + else { + Debug.fail("invalid action"); + } return { renameFilename: undefined, @@ -53,9 +60,18 @@ namespace ts.refactor.convertArrowFunction { }; } - function updateBraces(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, expression: Expression, addBraces: boolean) { - const body = addBraces ? createBlock([createReturn(expression)]) : expression; + function addBraces(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, expression: Expression) { + updateBraces(changeTracker, file, container, createBlock([createReturn(expression)])); + } + function removeBraces(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, expression: Expression) { + if (!isLiteralExpression(expression) && !isIdentifier(expression) && !isParenthesizedExpression(expression) && expression.kind !== SyntaxKind.NullKeyword) { + expression = createParen(expression); + } + updateBraces(changeTracker, file, container, expression); + } + + function updateBraces(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, body: ConciseBody) { const arrowFunction = updateArrowFunction( container, container.modifiers, @@ -78,12 +94,15 @@ namespace ts.refactor.convertArrowFunction { expression: container.body }; } - else if (container.body.statements.length === 1 && isReturnStatement(first(container.body.statements))) { - return { - container, - addBraces: false, - expression: (first(container.body.statements)).expression - }; + else if (container.body.statements.length === 1) { + const firstStatement = first(container.body.statements); + if (isReturnStatement(firstStatement)) { + return { + container, + addBraces: false, + expression: firstStatement.expression + }; + } } return undefined; } diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index f425c569e31..4d94facef35 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -114,7 +114,7 @@ "refactors/extractSymbol.ts", "refactors/generateGetAccessorAndSetAccessor.ts", "refactors/moveToNewFile.ts", - "refactors/convertArrowFunction.ts", + "refactors/addOrRemoveBracesToArrowFunction.ts", "sourcemaps.ts", "services.ts", "breakpoints.ts", diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction7.ts b/tests/cases/fourslash/refactorAddBracesToArrowFunction7.ts deleted file mode 100644 index 7f7a5207515..00000000000 --- a/tests/cases/fourslash/refactorAddBracesToArrowFunction7.ts +++ /dev/null @@ -1,6 +0,0 @@ -/// - -//// const foo = /*a*/a/*b*/ => { }; - -goTo.select("a", "b"); -verify.not.refactorAvailable("Convert arrow function"); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction1.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction1.ts similarity index 81% rename from tests/cases/fourslash/refactorAddBracesToArrowFunction1.ts rename to tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction1.ts index fde5a54656e..1d8d52e201f 100644 --- a/tests/cases/fourslash/refactorAddBracesToArrowFunction1.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction1.ts @@ -4,7 +4,7 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert arrow function", + refactorName: "Add or remove braces in an arrow function", actionName: "Add braces to arrow function", actionDescription: "Add braces to arrow function", newContent: `const foo = a => { return a + 1; };`, diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction10.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction10.ts new file mode 100644 index 00000000000..373172a2b31 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction10.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return (1, 2, 3); }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => (1, 2, 3);`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction11.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction11.ts new file mode 100644 index 00000000000..c634db625cf --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction11.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return 1, 2, 3; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => (1, 2, 3);`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction12.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction12.ts new file mode 100644 index 00000000000..aecf37c8b56 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction12.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return "foo"; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => "foo";`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction13.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction13.ts new file mode 100644 index 00000000000..64d1a02db67 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction13.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return null; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => null;`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction14.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction14.ts new file mode 100644 index 00000000000..b15f1cfad31 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction14.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return undefined; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => undefined;`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction15.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction15.ts new file mode 100644 index 00000000000..af2927f8f94 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction15.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return void 0; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => (void 0);`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction16.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction16.ts new file mode 100644 index 00000000000..87bdcfe5752 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction16.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return {}; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => ({});`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction17.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction17.ts new file mode 100644 index 00000000000..e71809ac38f --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction17.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return `abc{a}`; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => \`abc{a}\`;`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction18.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction18.ts new file mode 100644 index 00000000000..0e2d85ddd26 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction18.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return `abc`; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => \`abc\`;`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction19.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction19.ts new file mode 100644 index 00000000000..9d56a4d5f66 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction19.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return a; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => a;`, +}); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction2.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction2.ts similarity index 82% rename from tests/cases/fourslash/refactorAddBracesToArrowFunction2.ts rename to tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction2.ts index 30f4de0e9a7..d875018c397 100644 --- a/tests/cases/fourslash/refactorAddBracesToArrowFunction2.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction2.ts @@ -4,7 +4,7 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert arrow function", + refactorName: "Add or remove braces in an arrow function", actionName: "Add braces to arrow function", actionDescription: "Add braces to arrow function", newContent: `const foo = a => { return ({ a: 1 }); };`, diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction3.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction3.ts similarity index 81% rename from tests/cases/fourslash/refactorAddBracesToArrowFunction3.ts rename to tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction3.ts index cd2d773449e..ead5867a175 100644 --- a/tests/cases/fourslash/refactorAddBracesToArrowFunction3.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction3.ts @@ -4,7 +4,7 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert arrow function", + refactorName: "Add or remove braces in an arrow function", actionName: "Add braces to arrow function", actionDescription: "Add braces to arrow function", newContent: `const foo = a => { return 1; };`, diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction4.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction4.ts similarity index 70% rename from tests/cases/fourslash/refactorAddBracesToArrowFunction4.ts rename to tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction4.ts index f113d63add4..a2147af1d47 100644 --- a/tests/cases/fourslash/refactorAddBracesToArrowFunction4.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction4.ts @@ -4,8 +4,8 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert arrow function", + refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", - newContent: `const foo = a => a + 1;`, + newContent: `const foo = a => (a + 1);`, }); diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction5.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction5.ts similarity index 82% rename from tests/cases/fourslash/refactorAddBracesToArrowFunction5.ts rename to tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction5.ts index bc0cdfd6484..355f3a8f331 100644 --- a/tests/cases/fourslash/refactorAddBracesToArrowFunction5.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction5.ts @@ -4,7 +4,7 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert arrow function", + refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", newContent: `const foo = a => ({ a: 1 });`, diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction6.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction6.ts similarity index 82% rename from tests/cases/fourslash/refactorAddBracesToArrowFunction6.ts rename to tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction6.ts index 999fba05193..31f865b4394 100644 --- a/tests/cases/fourslash/refactorAddBracesToArrowFunction6.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction6.ts @@ -4,7 +4,7 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert arrow function", + refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", newContent: `const foo = a => 1;`, diff --git a/tests/cases/fourslash/refactorAddBracesToArrowFunction8.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction8.ts similarity index 66% rename from tests/cases/fourslash/refactorAddBracesToArrowFunction8.ts rename to tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction8.ts index 1c7f0bd954b..a2ec70e1e82 100644 --- a/tests/cases/fourslash/refactorAddBracesToArrowFunction8.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction8.ts @@ -6,4 +6,4 @@ //// }; goTo.select("a", "b"); -verify.not.refactorAvailable("Convert arrow function"); +verify.not.refactorAvailable("Add or remove braces in an arrow function"); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts new file mode 100644 index 00000000000..610e19cff45 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => (1, 2, 3); + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Add braces to arrow function", + actionDescription: "Add braces to arrow function", + newContent: `const foo = a => { return (1, 2, 3); };`, +}); From bd9a8b5c0cad409085583b07edcdf234319f805f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Wed, 18 Apr 2018 17:34:30 +0800 Subject: [PATCH 005/130] stash --- .../codefixes/convertFunctionToEs6Class.ts | 16 ------ .../addOrRemoveBracesToArrowFunction.ts | 55 ++++++++++--------- src/services/utilities.ts | 16 ++++++ ...actorAddOrRemoveBracesToArrowFunction15.ts | 2 +- ...actorAddOrRemoveBracesToArrowFunction20.ts | 14 +++++ ...actorAddOrRemoveBracesToArrowFunction21.ts | 11 ++++ ...factorAddOrRemoveBracesToArrowFunction4.ts | 2 +- 7 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts diff --git a/src/services/codefixes/convertFunctionToEs6Class.ts b/src/services/codefixes/convertFunctionToEs6Class.ts index cd1baeb14a0..4ce540595e3 100644 --- a/src/services/codefixes/convertFunctionToEs6Class.ts +++ b/src/services/codefixes/convertFunctionToEs6Class.ts @@ -202,22 +202,6 @@ namespace ts.codefix { } } - function copyComments(sourceNode: Node, targetNode: Node, sourceFile: SourceFile) { - forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, (pos, end, kind, htnl) => { - if (kind === SyntaxKind.MultiLineCommentTrivia) { - // Remove leading /* - pos += 2; - // Remove trailing */ - end -= 2; - } - else { - // Remove leading // - pos += 2; - } - addSyntheticLeadingComment(targetNode, kind, sourceFile.text.slice(pos, end), htnl); - }); - } - function getModifierKindFromSource(source: Node, kind: SyntaxKind): ReadonlyArray | undefined { return filter(source.modifiers, modifier => modifier.kind === kind); } diff --git a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts index df7cacadf3f..e6fed3ebaf7 100644 --- a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts +++ b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts @@ -9,7 +9,7 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { registerRefactor(refactorName, { getEditsForAction, getAvailableActions }); interface Info { - container: ArrowFunction; + func: ArrowFunction; expression: Expression; addBraces: boolean; } @@ -35,24 +35,31 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { }]; } - function getEditsForAction(context: RefactorContext, _actionName: string): RefactorEditInfo | undefined { + function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined { const { file, startPosition } = context; const info = getConvertibleArrowFunctionAtPosition(file, startPosition); if (!info) return undefined; - const { expression, container } = info; + const { expression, func } = info; const changeTracker = textChanges.ChangeTracker.fromContext(context); - if (_actionName === addBracesActionName) { - addBraces(changeTracker, file, container, expression); + let body: ConciseBody; + if (actionName === addBracesActionName) { + const returnStatement = createReturn(expression); + body = createBlock([returnStatement]); + copyComments(expression, returnStatement, file, SyntaxKind.SingleLineCommentTrivia, true); } - else if (_actionName === removeBracesActionName) { - removeBraces(changeTracker, file, container, expression); + else if (actionName === removeBracesActionName) { + const returnStatement = expression.parent; + body = needsParentheses(expression) ? createParen(expression) : expression; + copyComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, false); } else { - Debug.fail("invalid action"); + Debug.fail('invalid action'); } + updateBody(changeTracker, file, func, body); + return { renameFilename: undefined, renameLocation: undefined, @@ -60,18 +67,13 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { }; } - function addBraces(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, expression: Expression) { - updateBraces(changeTracker, file, container, createBlock([createReturn(expression)])); + function needsParentheses(expression: Expression) { + if (isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken) return true; + if (isObjectLiteralExpression(expression)) return true; + return false; } - function removeBraces(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, expression: Expression) { - if (!isLiteralExpression(expression) && !isIdentifier(expression) && !isParenthesizedExpression(expression) && expression.kind !== SyntaxKind.NullKeyword) { - expression = createParen(expression); - } - updateBraces(changeTracker, file, container, expression); - } - - function updateBraces(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, body: ConciseBody) { + function updateBody(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, body: ConciseBody) { const arrowFunction = updateArrowFunction( container, container.modifiers, @@ -84,21 +86,22 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { function getConvertibleArrowFunctionAtPosition(file: SourceFile, startPosition: number): Info | undefined { const node = getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); - const container = getContainingFunction(node); - if (!container || !isArrowFunction(container)) return undefined; + const func = getContainingFunction(node); + if (!func || !isArrowFunction(func)) return undefined; - if (isExpression(container.body)) { + if (isExpression(func.body)) { return { - container, + func, addBraces: true, - expression: container.body + expression: func.body }; } - else if (container.body.statements.length === 1) { - const firstStatement = first(container.body.statements); + else if (func.body.statements.length === 1) { + const firstStatement = first(func.body.statements); if (isReturnStatement(firstStatement)) { + return { - container, + func, addBraces: false, expression: firstStatement.expression }; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 54f88646071..987398f36f4 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1642,4 +1642,20 @@ namespace ts { Debug.assert(lastPos >= 0); return lastPos; } + + export function copyComments(sourceNode: Node, targetNode: Node, sourceFile: SourceFile, explicitKind?: CommentKind, explicitHtnl?: boolean) { + forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, (pos, end, kind, htnl) => { + if (kind === SyntaxKind.MultiLineCommentTrivia) { + // Remove leading /* + pos += 2; + // Remove trailing */ + end -= 2; + } + else { + // Remove leading // + pos += 2; + } + addSyntheticLeadingComment(targetNode, explicitKind || kind, sourceFile.text.slice(pos, end), explicitHtnl !== undefined ? explicitHtnl : htnl); + }); + } } diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction15.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction15.ts index af2927f8f94..7776a8b4737 100644 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction15.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction15.ts @@ -7,5 +7,5 @@ edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", - newContent: `const foo = a => (void 0);`, + newContent: `const foo = a => void 0;`, }); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts new file mode 100644 index 00000000000..9dde36a8f26 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts @@ -0,0 +1,14 @@ +/// + +//// const foo = /*a*/a/*b*/ => { +//// // return comment +//// return a; +//// }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => /* return comment */ a;`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts new file mode 100644 index 00000000000..97ca16bcb28 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => /* expression comment */ a + 1 + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => { /* expression comment */ return a + 1; }`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction4.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction4.ts index a2147af1d47..eb4e0939e2f 100644 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction4.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction4.ts @@ -7,5 +7,5 @@ edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", - newContent: `const foo = a => (a + 1);`, + newContent: `const foo = a => a + 1;`, }); From 0c06126d60b95ee69abda1eb6b3aed3a45815593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Wed, 25 Apr 2018 18:25:47 +0800 Subject: [PATCH 006/130] fix converter --- src/compiler/scanner.ts | 10 +++++----- .../addOrRemoveBracesToArrowFunction.ts | 7 ++++--- src/services/utilities.ts | 6 +++--- .../refactorAddOrRemoveBracesToArrowFunction1.ts | 4 +++- .../refactorAddOrRemoveBracesToArrowFunction2.ts | 4 +++- ...refactorAddOrRemoveBracesToArrowFunction20.ts | 2 +- ...refactorAddOrRemoveBracesToArrowFunction21.ts | 9 ++++++--- ...refactorAddOrRemoveBracesToArrowFunction22.ts | 16 ++++++++++++++++ .../refactorAddOrRemoveBracesToArrowFunction3.ts | 4 +++- .../refactorAddOrRemoveBracesToArrowFunction7.ts | 6 ++++++ .../refactorAddOrRemoveBracesToArrowFunction9.ts | 4 +++- 11 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction7.ts diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 8963285dc7a..2bcbed12835 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -626,13 +626,13 @@ namespace ts { * @returns If "reduce" is true, the accumulated value. If "reduce" is false, the first truthy * return value of the callback. */ - function iterateCommentRanges(reduce: boolean, text: string, pos: number, trailing: boolean, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U | undefined) => U, state: T, initial?: U): U | undefined { + function iterateCommentRanges(reduce: boolean, text: string, pos: number, trailing: boolean, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U | undefined) => U, state: T, initial?: U, inline?: boolean): U | undefined { let pendingPos!: number; let pendingEnd!: number; let pendingKind!: CommentKind; let pendingHasTrailingNewLine!: boolean; let hasPendingCommentRange = false; - let collecting = trailing || pos === 0; + let collecting = inline || trailing || pos === 0; let accumulator = initial; scan: while (pos >= 0 && pos < text.length) { const ch = text.charCodeAt(pos); @@ -725,9 +725,9 @@ namespace ts { } export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; - export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; - export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined { - return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state); + export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, inline?: boolean): U | undefined; + export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T, inline?: boolean): U | undefined { + return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state, /* initial */ undefined, inline); } export function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; diff --git a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts index e6fed3ebaf7..647bbbc5db6 100644 --- a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts +++ b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts @@ -46,12 +46,14 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { let body: ConciseBody; if (actionName === addBracesActionName) { const returnStatement = createReturn(expression); - body = createBlock([returnStatement]); - copyComments(expression, returnStatement, file, SyntaxKind.SingleLineCommentTrivia, true); + body = createBlock([returnStatement], /* multiLine */ true); + suppressLeadingAndTrailingTrivia(expression); + copyComments(expression, returnStatement, file, SyntaxKind.MultiLineCommentTrivia, true, true); } else if (actionName === removeBracesActionName) { const returnStatement = expression.parent; body = needsParentheses(expression) ? createParen(expression) : expression; + suppressLeadingAndTrailingTrivia(returnStatement); copyComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, false); } else { @@ -99,7 +101,6 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { else if (func.body.statements.length === 1) { const firstStatement = first(func.body.statements); if (isReturnStatement(firstStatement)) { - return { func, addBraces: false, diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 987398f36f4..acb995bf5bf 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1643,7 +1643,7 @@ namespace ts { return lastPos; } - export function copyComments(sourceNode: Node, targetNode: Node, sourceFile: SourceFile, explicitKind?: CommentKind, explicitHtnl?: boolean) { + export function copyComments(sourceNode: Node, targetNode: Node, sourceFile: SourceFile, explicitKind?: CommentKind, explicitHtnl?: boolean, inline?: boolean) { forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, (pos, end, kind, htnl) => { if (kind === SyntaxKind.MultiLineCommentTrivia) { // Remove leading /* @@ -1655,7 +1655,7 @@ namespace ts { // Remove leading // pos += 2; } - addSyntheticLeadingComment(targetNode, explicitKind || kind, sourceFile.text.slice(pos, end), explicitHtnl !== undefined ? explicitHtnl : htnl); - }); + addSyntheticLeadingComment(targetNode, explicitKind || kind, sourceFile.text.slice(pos, end), explicitHtnl !== undefined ? explicitHtnl : htnl); + }, undefined, inline) } } diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction1.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction1.ts index 1d8d52e201f..9671981dfcf 100644 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction1.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction1.ts @@ -7,5 +7,7 @@ edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Add braces to arrow function", actionDescription: "Add braces to arrow function", - newContent: `const foo = a => { return a + 1; };`, + newContent: `const foo = a => { + return a + 1; +};`, }); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction2.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction2.ts index d875018c397..2cce0dc5998 100644 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction2.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction2.ts @@ -7,5 +7,7 @@ edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Add braces to arrow function", actionDescription: "Add braces to arrow function", - newContent: `const foo = a => { return ({ a: 1 }); };`, + newContent: `const foo = a => { + return ({ a: 1 }); +};`, }); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts index 9dde36a8f26..f84e66898fe 100644 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts @@ -10,5 +10,5 @@ edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", - newContent: `const foo = a => /* return comment */ a;`, + newContent: `const foo = a => /* return comment*/ a;`, }); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts index 97ca16bcb28..4ba578ded89 100644 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts @@ -5,7 +5,10 @@ goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", - actionName: "Remove braces from arrow function", - actionDescription: "Remove braces from arrow function", - newContent: `const foo = a => { /* expression comment */ return a + 1; }`, + actionName: "Add braces to arrow function", + actionDescription: "Add braces to arrow function", + newContent: `const foo = a => { + /* expression comment */ + return a + 1; +}`, }); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts new file mode 100644 index 00000000000..9d179bcb935 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts @@ -0,0 +1,16 @@ +/// + +//// const foo = /*a*/a/*b*/ => +//// /* expression comment */ +//// a + 1 + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Add braces to arrow function", + actionDescription: "Add braces to arrow function", + newContent: `const foo = a => { + /* expression comment */ + return a + 1; +}`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction3.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction3.ts index ead5867a175..23710deb00b 100644 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction3.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction3.ts @@ -7,5 +7,7 @@ edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Add braces to arrow function", actionDescription: "Add braces to arrow function", - newContent: `const foo = a => { return 1; };`, + newContent: `const foo = a => { + return 1; +};`, }); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction7.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction7.ts new file mode 100644 index 00000000000..7a8690be4eb --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction7.ts @@ -0,0 +1,6 @@ +/// + +//// const foo = /*a*/a/*b*/ => { }; + +goTo.select("a", "b"); +verify.not.refactorAvailable("Add or remove braces in an arrow function"); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts index 610e19cff45..a7ba12a5996 100644 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts @@ -7,5 +7,7 @@ edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Add braces to arrow function", actionDescription: "Add braces to arrow function", - newContent: `const foo = a => { return (1, 2, 3); };`, + newContent: `const foo = a => { + return (1, 2, 3); +};`, }); From 1a59eb3949e275d9298a1fe53514252e4f7d5c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Thu, 26 Apr 2018 10:11:59 +0800 Subject: [PATCH 007/130] update body only --- .../addOrRemoveBracesToArrowFunction.ts | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts index 647bbbc5db6..cb6658f1409 100644 --- a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts +++ b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts @@ -41,49 +41,34 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { if (!info) return undefined; const { expression, func } = info; - const changeTracker = textChanges.ChangeTracker.fromContext(context); let body: ConciseBody; if (actionName === addBracesActionName) { const returnStatement = createReturn(expression); body = createBlock([returnStatement], /* multiLine */ true); - suppressLeadingAndTrailingTrivia(expression); + suppressLeadingAndTrailingTrivia(body); copyComments(expression, returnStatement, file, SyntaxKind.MultiLineCommentTrivia, true, true); } else if (actionName === removeBracesActionName) { const returnStatement = expression.parent; body = needsParentheses(expression) ? createParen(expression) : expression; - suppressLeadingAndTrailingTrivia(returnStatement); + suppressLeadingAndTrailingTrivia(body); copyComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, false); } else { Debug.fail('invalid action'); } - updateBody(changeTracker, file, func, body); - - return { - renameFilename: undefined, - renameLocation: undefined, - edits: changeTracker.getChanges() - }; + const edits = textChanges.ChangeTracker.with(context, t => updateBody(t, file, func, body)); + return { renameFilename: undefined, renameLocation: undefined, edits }; } function needsParentheses(expression: Expression) { - if (isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken) return true; - if (isObjectLiteralExpression(expression)) return true; - return false; + return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken || isObjectLiteralExpression(expression); } function updateBody(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, body: ConciseBody) { - const arrowFunction = updateArrowFunction( - container, - container.modifiers, - container.typeParameters, - container.parameters, - container.type, - body); - changeTracker.replaceNode(file, container, arrowFunction); + changeTracker.replaceNode(file, container.body, body); } function getConvertibleArrowFunctionAtPosition(file: SourceFile, startPosition: number): Info | undefined { From b6669c93c0799a0d7ee252cbf4ea650c00c01a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Wed, 23 May 2018 10:27:10 +0800 Subject: [PATCH 008/130] revert wrong inline parameter --- src/compiler/scanner.ts | 10 +++++----- src/services/utilities.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 2bcbed12835..9ed6b89ccc8 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -626,13 +626,13 @@ namespace ts { * @returns If "reduce" is true, the accumulated value. If "reduce" is false, the first truthy * return value of the callback. */ - function iterateCommentRanges(reduce: boolean, text: string, pos: number, trailing: boolean, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U | undefined) => U, state: T, initial?: U, inline?: boolean): U | undefined { + function iterateCommentRanges(reduce: boolean, text: string, pos: number, trailing: boolean, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U | undefined) => U, state: T, initial?: U): U | undefined { let pendingPos!: number; let pendingEnd!: number; let pendingKind!: CommentKind; let pendingHasTrailingNewLine!: boolean; let hasPendingCommentRange = false; - let collecting = inline || trailing || pos === 0; + let collecting = trailing || pos === 0; let accumulator = initial; scan: while (pos >= 0 && pos < text.length) { const ch = text.charCodeAt(pos); @@ -725,9 +725,9 @@ namespace ts { } export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; - export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, inline?: boolean): U | undefined; - export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T, inline?: boolean): U | undefined { - return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state, /* initial */ undefined, inline); + export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; + export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined { + return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state, /* initial */ undefined); } export function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index acb995bf5bf..ca65a41fd24 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1656,6 +1656,6 @@ namespace ts { pos += 2; } addSyntheticLeadingComment(targetNode, explicitKind || kind, sourceFile.text.slice(pos, end), explicitHtnl !== undefined ? explicitHtnl : htnl); - }, undefined, inline) + }) } } From de75f14d2b8630f9a9d6ccc52238a8a91bf870bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Wed, 23 May 2018 10:49:57 +0800 Subject: [PATCH 009/130] fix void return statement --- .../addOrRemoveBracesToArrowFunction.ts | 20 ++++++++++--------- src/services/utilities.ts | 4 ++-- ...actorAddOrRemoveBracesToArrowFunction23.ts | 13 ++++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts diff --git a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts index cb6658f1409..cf747863954 100644 --- a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts +++ b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts @@ -10,7 +10,8 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { interface Info { func: ArrowFunction; - expression: Expression; + expression: Expression | undefined; + returnStatement?: ReturnStatement; addBraces: boolean; } @@ -40,23 +41,23 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { const info = getConvertibleArrowFunctionAtPosition(file, startPosition); if (!info) return undefined; - const { expression, func } = info; + const { expression, returnStatement, func } = info; let body: ConciseBody; if (actionName === addBracesActionName) { const returnStatement = createReturn(expression); body = createBlock([returnStatement], /* multiLine */ true); suppressLeadingAndTrailingTrivia(body); - copyComments(expression, returnStatement, file, SyntaxKind.MultiLineCommentTrivia, true, true); + copyComments(expression!, returnStatement, file, SyntaxKind.MultiLineCommentTrivia, /* explicitHtnl */ true); } - else if (actionName === removeBracesActionName) { - const returnStatement = expression.parent; - body = needsParentheses(expression) ? createParen(expression) : expression; + else if (actionName === removeBracesActionName && returnStatement) { + const actualExpression = expression || createVoidZero(); + body = needsParentheses(actualExpression) ? createParen(actualExpression) : actualExpression; suppressLeadingAndTrailingTrivia(body); - copyComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, false); + copyComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* explicitHtnl */ false); } else { - Debug.fail('invalid action'); + Debug.fail("invalid action"); } const edits = textChanges.ChangeTracker.with(context, t => updateBody(t, file, func, body)); @@ -89,7 +90,8 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { return { func, addBraces: false, - expression: firstStatement.expression + expression: firstStatement.expression, + returnStatement: firstStatement }; } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index ca65a41fd24..535f35eb48d 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1643,7 +1643,7 @@ namespace ts { return lastPos; } - export function copyComments(sourceNode: Node, targetNode: Node, sourceFile: SourceFile, explicitKind?: CommentKind, explicitHtnl?: boolean, inline?: boolean) { + export function copyComments(sourceNode: Node, targetNode: Node, sourceFile: SourceFile, explicitKind?: CommentKind, explicitHtnl?: boolean) { forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, (pos, end, kind, htnl) => { if (kind === SyntaxKind.MultiLineCommentTrivia) { // Remove leading /* @@ -1656,6 +1656,6 @@ namespace ts { pos += 2; } addSyntheticLeadingComment(targetNode, explicitKind || kind, sourceFile.text.slice(pos, end), explicitHtnl !== undefined ? explicitHtnl : htnl); - }) + }); } } diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts new file mode 100644 index 00000000000..062ae3f674e --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts @@ -0,0 +1,13 @@ +/// + +//// const foo = /*a*/a/*b*/ => { +//// return; +//// }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => void 0`, +}); From 5497b42558c839cf66ca8dafb79438c0e19d5b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Thu, 24 May 2018 18:00:42 +0800 Subject: [PATCH 010/130] remove some case --- ...refactorAddOrRemoveBracesToArrowFunction22.ts | 16 ---------------- ...refactorAddOrRemoveBracesToArrowFunction23.ts | 13 ------------- 2 files changed, 29 deletions(-) delete mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts delete mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts deleted file mode 100644 index 9d179bcb935..00000000000 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// - -//// const foo = /*a*/a/*b*/ => -//// /* expression comment */ -//// a + 1 - -goTo.select("a", "b"); -edit.applyRefactor({ - refactorName: "Add or remove braces in an arrow function", - actionName: "Add braces to arrow function", - actionDescription: "Add braces to arrow function", - newContent: `const foo = a => { - /* expression comment */ - return a + 1; -}`, -}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts deleted file mode 100644 index 062ae3f674e..00000000000 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -//// const foo = /*a*/a/*b*/ => { -//// return; -//// }; - -goTo.select("a", "b"); -edit.applyRefactor({ - refactorName: "Add or remove braces in an arrow function", - actionName: "Remove braces from arrow function", - actionDescription: "Remove braces from arrow function", - newContent: `const foo = a => void 0`, -}); From 3d9a6ab068de2d94c7e35e5c107dce231d3cba89 Mon Sep 17 00:00:00 2001 From: kingwl Date: Thu, 24 May 2018 22:28:30 +0800 Subject: [PATCH 011/130] remove failed test --- .../refactorAddOrRemoveBracesToArrowFunction21.ts | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts deleted file mode 100644 index 4ba578ded89..00000000000 --- a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -//// const foo = /*a*/a/*b*/ => /* expression comment */ a + 1 - -goTo.select("a", "b"); -edit.applyRefactor({ - refactorName: "Add or remove braces in an arrow function", - actionName: "Add braces to arrow function", - actionDescription: "Add braces to arrow function", - newContent: `const foo = a => { - /* expression comment */ - return a + 1; -}`, -}); From 590476bf060d3089e4deb6afc13193eeaa1dcb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Fri, 25 May 2018 10:25:52 +0800 Subject: [PATCH 012/130] add more test and fix others --- src/compiler/scanner.ts | 2 +- .../addOrRemoveBracesToArrowFunction.ts | 12 +++------ src/services/utilities.ts | 4 +-- ...actorAddOrRemoveBracesToArrowFunction21.ts | 11 ++++++++ ...actorAddOrRemoveBracesToArrowFunction22.ts | 27 +++++++++++++++++++ ...actorAddOrRemoveBracesToArrowFunction23.ts | 18 +++++++++++++ 6 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 9c4dfbe9673..41b65c67864 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -727,7 +727,7 @@ namespace ts { export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined { - return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state, /* initial */ undefined); + return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state); } export function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; diff --git a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts index cf747863954..e982412ed7a 100644 --- a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts +++ b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts @@ -48,19 +48,19 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { const returnStatement = createReturn(expression); body = createBlock([returnStatement], /* multiLine */ true); suppressLeadingAndTrailingTrivia(body); - copyComments(expression!, returnStatement, file, SyntaxKind.MultiLineCommentTrivia, /* explicitHtnl */ true); + copyComments(expression!, returnStatement, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesActionName && returnStatement) { const actualExpression = expression || createVoidZero(); body = needsParentheses(actualExpression) ? createParen(actualExpression) : actualExpression; suppressLeadingAndTrailingTrivia(body); - copyComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* explicitHtnl */ false); + copyComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false); } else { Debug.fail("invalid action"); } - const edits = textChanges.ChangeTracker.with(context, t => updateBody(t, file, func, body)); + const edits = textChanges.ChangeTracker.with(context, t => t.replaceNode(file, func.body, body)); return { renameFilename: undefined, renameLocation: undefined, edits }; } @@ -68,14 +68,10 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken || isObjectLiteralExpression(expression); } - function updateBody(changeTracker: textChanges.ChangeTracker, file: SourceFile, container: ArrowFunction, body: ConciseBody) { - changeTracker.replaceNode(file, container.body, body); - } - function getConvertibleArrowFunctionAtPosition(file: SourceFile, startPosition: number): Info | undefined { const node = getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); const func = getContainingFunction(node); - if (!func || !isArrowFunction(func)) return undefined; + if (!func || !isArrowFunction(func) || (!rangeContainsRange(func, node) || rangeContainsRange(func.body, node))) return undefined; if (isExpression(func.body)) { return { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 199ef0fea98..babe95e57a0 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1650,7 +1650,7 @@ namespace ts { return lastPos; } - export function copyComments(sourceNode: Node, targetNode: Node, sourceFile: SourceFile, explicitKind?: CommentKind, explicitHtnl?: boolean) { + export function copyComments(sourceNode: Node, targetNode: Node, sourceFile: SourceFile, commentKind?: CommentKind, hasTrailingNewLine?: boolean) { forEachLeadingCommentRange(sourceFile.text, sourceNode.pos, (pos, end, kind, htnl) => { if (kind === SyntaxKind.MultiLineCommentTrivia) { // Remove leading /* @@ -1662,7 +1662,7 @@ namespace ts { // Remove leading // pos += 2; } - addSyntheticLeadingComment(targetNode, explicitKind || kind, sourceFile.text.slice(pos, end), explicitHtnl !== undefined ? explicitHtnl : htnl); + addSyntheticLeadingComment(targetNode, commentKind || kind, sourceFile.text.slice(pos, end), hasTrailingNewLine !== undefined ? hasTrailingNewLine : htnl); }); } } diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts new file mode 100644 index 00000000000..133940551a7 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts @@ -0,0 +1,11 @@ +/// + +//// const foo = /*a*/a/*b*/ => { return; }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const foo = a => void 0;`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts new file mode 100644 index 00000000000..5c5f973824d --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts @@ -0,0 +1,27 @@ +/// + +//// const /*a*/foo/*b*/ = /*c*/(/*d*//*e*/aa/*f*/aa, /*g*/b/*h*/) /*i*//*j*/ /*k*/=>/*l*/ /*m*/{/*n*/ /*o*/return/*p*/ 1; }; + +goTo.select("a", "b"); +verify.not.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function") + +goTo.select("c", "d"); +verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function") + +goTo.select("e", "f"); +verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function") + +goTo.select("g", "h"); +verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function") + +goTo.select("i", "j"); +verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function") + +goTo.select("k", "l"); +verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function") + +goTo.select("m", "n"); +verify.not.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function") + +goTo.select("o", "p"); +verify.not.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function") diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts new file mode 100644 index 00000000000..4c39ddbd306 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts @@ -0,0 +1,18 @@ +/// + +//// const /*a*/foo/*b*/ = /*c*/()/*d*/ /*e*//*f*/ /*g*/=>/*h*/ /*i*/1/*j*/; + +goTo.select("a", "b"); +verify.not.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function") + +goTo.select("c", "d"); +verify.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function") + +goTo.select("e", "f"); +verify.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function") + +goTo.select("g", "h"); +verify.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function") + +goTo.select("i", "j"); +verify.not.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function") From 9767fbba092a3fa9fa5c7e6a6d4908c30c4c1565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Mon, 4 Jun 2018 15:16:59 +0800 Subject: [PATCH 013/130] allow access protected member in this parameter context --- src/compiler/checker.ts | 13 +- .../thisTypeAccessibility.errors.txt | 44 ++++++ .../reference/thisTypeAccessibility.js | 59 ++++++++ .../reference/thisTypeAccessibility.symbols | 125 +++++++++++++++ .../reference/thisTypeAccessibility.types | 142 ++++++++++++++++++ .../types/thisType/thisTypeAccessibility.ts | 31 ++++ 6 files changed, 411 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/thisTypeAccessibility.errors.txt create mode 100644 tests/baselines/reference/thisTypeAccessibility.js create mode 100644 tests/baselines/reference/thisTypeAccessibility.symbols create mode 100644 tests/baselines/reference/thisTypeAccessibility.types create mode 100644 tests/cases/conformance/types/thisType/thisTypeAccessibility.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9306907b418..a9243186802 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17101,14 +17101,21 @@ namespace ts { // Find the first enclosing class that has the declaring classes of the protected constituents // of the property as base classes - const enclosingClass = forEachEnclosingClass(node, enclosingDeclaration => { + let enclosingClass = forEachEnclosingClass(node, enclosingDeclaration => { const enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)!); return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { - error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); - return false; + let thisParameter: ParameterDeclaration | undefined; + const thisContainer = getThisContainer(node, /* includeArrowFunctions */ false); + if (!thisContainer || !isFunctionLike(thisContainer) || !(thisParameter = getThisParameter(thisContainer)) || !thisParameter.type) { + error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + return false; + } + + const thisType = getTypeFromTypeNode(thisParameter.type); + enclosingClass = ((thisType.flags & TypeFlags.TypeParameter) ? getConstraintFromTypeParameter(thisType) : thisType) as InterfaceType; } // No further restrictions for static properties if (flags & ModifierFlags.Static) { diff --git a/tests/baselines/reference/thisTypeAccessibility.errors.txt b/tests/baselines/reference/thisTypeAccessibility.errors.txt new file mode 100644 index 00000000000..bfdc297fa83 --- /dev/null +++ b/tests/baselines/reference/thisTypeAccessibility.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(14,10): error TS2341: Property 'p' is private and only accessible within class 'MyClass'. +tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(20,10): error TS2341: Property 'p' is private and only accessible within class 'MyClass'. +tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(26,10): error TS2341: Property 'p' is private and only accessible within class 'MyClass'. + + +==== tests/cases/conformance/types/thisType/thisTypeAccessibility.ts (3 errors) ==== + class MyClass { + private p: number = 123; + protected pp: number = 123; + public ppp: number = 123; + } + + interface MyClass { + extension1(p: number): void; + extension2(p: number): void; + extension3(p: number): void; + } + + MyClass.prototype.extension1 = function (this: MyClass, p: number) { + this.p = p; + ~ +!!! error TS2341: Property 'p' is private and only accessible within class 'MyClass'. + this.pp = p; + this.ppp = p; + } + + MyClass.prototype.extension2 = function (this: T, p: number) { + this.p = p; + ~ +!!! error TS2341: Property 'p' is private and only accessible within class 'MyClass'. + this.pp = p; + this.ppp = p; + } + + function extension3 (this: T, p: number) { + this.p = p; + ~ +!!! error TS2341: Property 'p' is private and only accessible within class 'MyClass'. + this.pp = p; + this.ppp = p; + } + + MyClass.prototype.extension3 = extension3; + \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeAccessibility.js b/tests/baselines/reference/thisTypeAccessibility.js new file mode 100644 index 00000000000..a2695d1d670 --- /dev/null +++ b/tests/baselines/reference/thisTypeAccessibility.js @@ -0,0 +1,59 @@ +//// [thisTypeAccessibility.ts] +class MyClass { + private p: number = 123; + protected pp: number = 123; + public ppp: number = 123; +} + +interface MyClass { + extension1(p: number): void; + extension2(p: number): void; + extension3(p: number): void; +} + +MyClass.prototype.extension1 = function (this: MyClass, p: number) { + this.p = p; + this.pp = p; + this.ppp = p; +} + +MyClass.prototype.extension2 = function (this: T, p: number) { + this.p = p; + this.pp = p; + this.ppp = p; +} + +function extension3 (this: T, p: number) { + this.p = p; + this.pp = p; + this.ppp = p; +} + +MyClass.prototype.extension3 = extension3; + + +//// [thisTypeAccessibility.js] +var MyClass = /** @class */ (function () { + function MyClass() { + this.p = 123; + this.pp = 123; + this.ppp = 123; + } + return MyClass; +}()); +MyClass.prototype.extension1 = function (p) { + this.p = p; + this.pp = p; + this.ppp = p; +}; +MyClass.prototype.extension2 = function (p) { + this.p = p; + this.pp = p; + this.ppp = p; +}; +function extension3(p) { + this.p = p; + this.pp = p; + this.ppp = p; +} +MyClass.prototype.extension3 = extension3; diff --git a/tests/baselines/reference/thisTypeAccessibility.symbols b/tests/baselines/reference/thisTypeAccessibility.symbols new file mode 100644 index 00000000000..0919d83f8e4 --- /dev/null +++ b/tests/baselines/reference/thisTypeAccessibility.symbols @@ -0,0 +1,125 @@ +=== tests/cases/conformance/types/thisType/thisTypeAccessibility.ts === +class MyClass { +>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 4, 1)) + + private p: number = 123; +>p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15)) + + protected pp: number = 123; +>pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28)) + + public ppp: number = 123; +>ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31)) +} + +interface MyClass { +>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 4, 1)) + + extension1(p: number): void; +>extension1 : Symbol(MyClass.extension1, Decl(thisTypeAccessibility.ts, 6, 19)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 7, 15)) + + extension2(p: number): void; +>extension2 : Symbol(MyClass.extension2, Decl(thisTypeAccessibility.ts, 7, 32)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 8, 15)) + + extension3(p: number): void; +>extension3 : Symbol(MyClass.extension3, Decl(thisTypeAccessibility.ts, 8, 32)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 9, 15)) +} + +MyClass.prototype.extension1 = function (this: MyClass, p: number) { +>MyClass.prototype.extension1 : Symbol(MyClass.extension1, Decl(thisTypeAccessibility.ts, 6, 19)) +>MyClass.prototype : Symbol(MyClass.prototype) +>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 4, 1)) +>prototype : Symbol(MyClass.prototype) +>extension1 : Symbol(MyClass.extension1, Decl(thisTypeAccessibility.ts, 6, 19)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 12, 41)) +>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 4, 1)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 12, 55)) + + this.p = p; +>this.p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 12, 41)) +>p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 12, 55)) + + this.pp = p; +>this.pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 12, 41)) +>pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 12, 55)) + + this.ppp = p; +>this.ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 12, 41)) +>ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 12, 55)) +} + +MyClass.prototype.extension2 = function (this: T, p: number) { +>MyClass.prototype.extension2 : Symbol(MyClass.extension2, Decl(thisTypeAccessibility.ts, 7, 32)) +>MyClass.prototype : Symbol(MyClass.prototype) +>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 4, 1)) +>prototype : Symbol(MyClass.prototype) +>extension2 : Symbol(MyClass.extension2, Decl(thisTypeAccessibility.ts, 7, 32)) +>T : Symbol(T, Decl(thisTypeAccessibility.ts, 18, 40)) +>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 4, 1)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 18, 60)) +>T : Symbol(T, Decl(thisTypeAccessibility.ts, 18, 40)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 18, 68)) + + this.p = p; +>this.p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 18, 60)) +>p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 18, 68)) + + this.pp = p; +>this.pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 18, 60)) +>pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 18, 68)) + + this.ppp = p; +>this.ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 18, 60)) +>ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 18, 68)) +} + +function extension3 (this: T, p: number) { +>extension3 : Symbol(extension3, Decl(thisTypeAccessibility.ts, 22, 1)) +>T : Symbol(T, Decl(thisTypeAccessibility.ts, 24, 20)) +>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 4, 1)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 24, 40)) +>T : Symbol(T, Decl(thisTypeAccessibility.ts, 24, 20)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 48)) + + this.p = p; +>this.p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 24, 40)) +>p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 48)) + + this.pp = p; +>this.pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 24, 40)) +>pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 48)) + + this.ppp = p; +>this.ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31)) +>this : Symbol(this, Decl(thisTypeAccessibility.ts, 24, 40)) +>ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31)) +>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 48)) +} + +MyClass.prototype.extension3 = extension3; +>MyClass.prototype.extension3 : Symbol(MyClass.extension3, Decl(thisTypeAccessibility.ts, 8, 32)) +>MyClass.prototype : Symbol(MyClass.prototype) +>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 4, 1)) +>prototype : Symbol(MyClass.prototype) +>extension3 : Symbol(MyClass.extension3, Decl(thisTypeAccessibility.ts, 8, 32)) +>extension3 : Symbol(extension3, Decl(thisTypeAccessibility.ts, 22, 1)) + diff --git a/tests/baselines/reference/thisTypeAccessibility.types b/tests/baselines/reference/thisTypeAccessibility.types new file mode 100644 index 00000000000..3eb0f46f1b7 --- /dev/null +++ b/tests/baselines/reference/thisTypeAccessibility.types @@ -0,0 +1,142 @@ +=== tests/cases/conformance/types/thisType/thisTypeAccessibility.ts === +class MyClass { +>MyClass : MyClass + + private p: number = 123; +>p : number +>123 : 123 + + protected pp: number = 123; +>pp : number +>123 : 123 + + public ppp: number = 123; +>ppp : number +>123 : 123 +} + +interface MyClass { +>MyClass : MyClass + + extension1(p: number): void; +>extension1 : (p: number) => void +>p : number + + extension2(p: number): void; +>extension2 : (p: number) => void +>p : number + + extension3(p: number): void; +>extension3 : (p: number) => void +>p : number +} + +MyClass.prototype.extension1 = function (this: MyClass, p: number) { +>MyClass.prototype.extension1 = function (this: MyClass, p: number) { this.p = p; this.pp = p; this.ppp = p;} : (this: MyClass, p: number) => void +>MyClass.prototype.extension1 : (p: number) => void +>MyClass.prototype : MyClass +>MyClass : typeof MyClass +>prototype : MyClass +>extension1 : (p: number) => void +>function (this: MyClass, p: number) { this.p = p; this.pp = p; this.ppp = p;} : (this: MyClass, p: number) => void +>this : MyClass +>MyClass : MyClass +>p : number + + this.p = p; +>this.p = p : number +>this.p : number +>this : MyClass +>p : number +>p : number + + this.pp = p; +>this.pp = p : number +>this.pp : number +>this : MyClass +>pp : number +>p : number + + this.ppp = p; +>this.ppp = p : number +>this.ppp : number +>this : MyClass +>ppp : number +>p : number +} + +MyClass.prototype.extension2 = function (this: T, p: number) { +>MyClass.prototype.extension2 = function (this: T, p: number) { this.p = p; this.pp = p; this.ppp = p;} : (this: T, p: number) => void +>MyClass.prototype.extension2 : (p: number) => void +>MyClass.prototype : MyClass +>MyClass : typeof MyClass +>prototype : MyClass +>extension2 : (p: number) => void +>function (this: T, p: number) { this.p = p; this.pp = p; this.ppp = p;} : (this: T, p: number) => void +>T : T +>MyClass : MyClass +>this : T +>T : T +>p : number + + this.p = p; +>this.p = p : number +>this.p : number +>this : T +>p : number +>p : number + + this.pp = p; +>this.pp = p : number +>this.pp : number +>this : T +>pp : number +>p : number + + this.ppp = p; +>this.ppp = p : number +>this.ppp : number +>this : T +>ppp : number +>p : number +} + +function extension3 (this: T, p: number) { +>extension3 : (this: T, p: number) => void +>T : T +>MyClass : MyClass +>this : T +>T : T +>p : number + + this.p = p; +>this.p = p : number +>this.p : number +>this : T +>p : number +>p : number + + this.pp = p; +>this.pp = p : number +>this.pp : number +>this : T +>pp : number +>p : number + + this.ppp = p; +>this.ppp = p : number +>this.ppp : number +>this : T +>ppp : number +>p : number +} + +MyClass.prototype.extension3 = extension3; +>MyClass.prototype.extension3 = extension3 : (this: T, p: number) => void +>MyClass.prototype.extension3 : (p: number) => void +>MyClass.prototype : MyClass +>MyClass : typeof MyClass +>prototype : MyClass +>extension3 : (p: number) => void +>extension3 : (this: T, p: number) => void + diff --git a/tests/cases/conformance/types/thisType/thisTypeAccessibility.ts b/tests/cases/conformance/types/thisType/thisTypeAccessibility.ts new file mode 100644 index 00000000000..28d55222d5a --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeAccessibility.ts @@ -0,0 +1,31 @@ +class MyClass { + private p: number = 123; + protected pp: number = 123; + public ppp: number = 123; +} + +interface MyClass { + extension1(p: number): void; + extension2(p: number): void; + extension3(p: number): void; +} + +MyClass.prototype.extension1 = function (this: MyClass, p: number) { + this.p = p; + this.pp = p; + this.ppp = p; +} + +MyClass.prototype.extension2 = function (this: T, p: number) { + this.p = p; + this.pp = p; + this.ppp = p; +} + +function extension3 (this: T, p: number) { + this.p = p; + this.pp = p; + this.ppp = p; +} + +MyClass.prototype.extension3 = extension3; From 42a5f815704e7bd0ccec6e512c369054024b7639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 19 May 2018 10:47:16 +0200 Subject: [PATCH 014/130] Use redefining helper pattern for better tree-shakeability --- src/compiler/transformers/es2015.ts | 10 +++++++--- src/compiler/transformers/esnext.ts | 17 ++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index b05cabcd85a..7cfd4fdc664 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -4072,9 +4072,13 @@ namespace ts { priority: 0, text: ` var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + function extendStatics(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 49453139947..cf1c6c447be 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -890,13 +890,16 @@ namespace ts { scoped: false, priority: 1, text: ` - var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; + var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); };` }; From 3af425b87d60d5f7ba2865d4b5feb3cbf1554cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Fri, 1 Jun 2018 00:08:54 +0200 Subject: [PATCH 015/130] Update baseline tests --- src/compiler/transformers/es2015.ts | 2 +- ...sClassHeritageListMemberTypeAnnotations.js | 9 +- ...accessibleTypeInTypeParameterConstraint.js | 9 +- .../reference/abstractClassInLocalScope.js | 9 +- .../abstractClassInLocalScopeIsAbstract.js | 9 +- tests/baselines/reference/abstractProperty.js | 9 +- .../reference/abstractPropertyNegative.js | 9 +- .../accessOverriddenBaseClassMember1.js | 9 +- .../accessors_spec_section-4.5_inference.js | 9 +- .../reference/aliasUsageInAccessorsOfClass.js | 9 +- .../baselines/reference/aliasUsageInArray.js | 9 +- .../aliasUsageInFunctionExpression.js | 9 +- .../reference/aliasUsageInGenericFunction.js | 9 +- .../reference/aliasUsageInIndexerOfClass.js | 9 +- .../reference/aliasUsageInObjectLiteral.js | 9 +- .../reference/aliasUsageInOrExpression.js | 9 +- ...aliasUsageInTypeArgumentOfExtendsClause.js | 18 +- .../reference/aliasUsageInVarAssignment.js | 9 +- .../reference/ambiguousOverloadResolution.js | 9 +- .../amdDeclarationEmitNoExtraDeclare.js | 9 +- ...ClassDeclarationDoesntPrintWithReadonly.js | 9 +- .../reference/apparentTypeSubtyping.js | 9 +- .../reference/apparentTypeSupertype.js | 9 +- .../reference/arrayAssignmentTest1.js | 9 +- .../reference/arrayAssignmentTest2.js | 9 +- .../reference/arrayBestCommonTypes.js | 9 +- .../reference/arrayLiteralTypeInference.js | 9 +- tests/baselines/reference/arrayLiterals.js | 9 +- .../arrayLiteralsWithRecursiveGenerics.js | 9 +- ...rayOfSubtypeIsAssignableToReadonlyArray.js | 9 +- .../reference/arrowFunctionContexts.js | 9 +- .../assignmentCompatWithCallSignatures3.js | 9 +- .../assignmentCompatWithCallSignatures4.js | 9 +- .../assignmentCompatWithCallSignatures5.js | 9 +- .../assignmentCompatWithCallSignatures6.js | 9 +- ...ssignmentCompatWithConstructSignatures3.js | 9 +- ...ssignmentCompatWithConstructSignatures4.js | 9 +- ...ssignmentCompatWithConstructSignatures5.js | 9 +- ...ssignmentCompatWithConstructSignatures6.js | 9 +- .../assignmentCompatWithNumericIndexer.js | 9 +- .../assignmentCompatWithNumericIndexer3.js | 9 +- .../assignmentCompatWithObjectMembers4.js | 9 +- ...nmentCompatWithObjectMembersOptionality.js | 9 +- ...mentCompatWithObjectMembersOptionality2.js | 9 +- .../assignmentCompatWithStringIndexer.js | 9 +- .../reference/assignmentLHSIsValue.js | 9 +- .../reference/asyncImportedPromise_es5.js | 9 +- tests/baselines/reference/autolift4.js | 9 +- tests/baselines/reference/baseCheck.js | 9 +- .../baseClassImprovedMismatchErrors.js | 9 +- .../reference/baseConstraintOfDecorator.js | 9 +- .../reference/baseExpressionTypeParameters.js | 9 +- .../reference/baseIndexSignatureResolution.js | 9 +- .../reference/baseTypeOrderChecking.js | 9 +- .../baseTypeWrappingInstantiationChain.js | 9 +- tests/baselines/reference/bases.js | 9 +- .../bestCommonTypeOfConditionalExpressions.js | 9 +- ...bestCommonTypeOfConditionalExpressions2.js | 9 +- .../reference/bestCommonTypeOfTuple2.js | 9 +- ...allSignatureAssignabilityInInheritance2.js | 9 +- ...allSignatureAssignabilityInInheritance3.js | 9 +- ...allSignatureAssignabilityInInheritance4.js | 9 +- ...allSignatureAssignabilityInInheritance5.js | 9 +- ...allSignatureAssignabilityInInheritance6.js | 9 +- tests/baselines/reference/callWithSpread.js | 9 +- ...captureSuperPropertyAccessInSuperCall01.js | 9 +- .../reference/captureThisInSuperCall.js | 9 +- tests/baselines/reference/castingTuple.js | 9 +- .../baselines/reference/chainedAssignment3.js | 9 +- ...arameterConstrainedToOtherTypeParameter.js | 9 +- .../reference/checkForObjectTooStrict.js | 9 +- .../reference/checkJsxChildrenProperty12.js | 9 +- .../reference/checkJsxChildrenProperty13.js | 9 +- .../reference/checkJsxChildrenProperty14.js | 9 +- .../reference/checkJsxChildrenProperty3.js | 9 +- .../reference/checkJsxChildrenProperty4.js | 9 +- .../reference/checkJsxChildrenProperty5.js | 9 +- .../reference/checkJsxChildrenProperty6.js | 9 +- .../reference/checkJsxChildrenProperty7.js | 9 +- .../reference/checkJsxChildrenProperty8.js | 9 +- .../checkSuperCallBeforeThisAccessing1.js | 9 +- .../checkSuperCallBeforeThisAccessing2.js | 9 +- .../checkSuperCallBeforeThisAccessing3.js | 9 +- .../checkSuperCallBeforeThisAccessing4.js | 9 +- .../checkSuperCallBeforeThisAccessing5.js | 9 +- .../checkSuperCallBeforeThisAccessing6.js | 9 +- .../checkSuperCallBeforeThisAccessing7.js | 9 +- .../checkSuperCallBeforeThisAccessing8.js | 9 +- ...ircularConstraintYieldsAppropriateError.js | 9 +- .../reference/circularImportAlias.js | 9 +- .../circularTypeofWithFunctionModule.js | 9 +- .../classAbstractConstructorAssignability.js | 9 +- .../reference/classAbstractCrashedOnce.js | 9 +- .../reference/classAbstractExtends.js | 9 +- .../reference/classAbstractFactoryFunction.js | 9 +- .../reference/classAbstractGeneric.js | 9 +- .../reference/classAbstractInAModule.js | 9 +- .../reference/classAbstractInheritance.js | 9 +- .../reference/classAbstractInstantiations1.js | 9 +- .../reference/classAbstractInstantiations2.js | 9 +- .../classAbstractOverrideWithAbstract.js | 9 +- .../reference/classAbstractSuperCalls.js | 9 +- .../classAbstractUsingAbstractMethod1.js | 9 +- .../classAbstractUsingAbstractMethods2.js | 9 +- .../classConstructorAccessibility2.js | 9 +- .../classConstructorAccessibility4.js | 9 +- .../classConstructorAccessibility5.js | 9 +- ...classConstructorParametersAccessibility.js | 9 +- ...lassConstructorParametersAccessibility2.js | 9 +- ...lassConstructorParametersAccessibility3.js | 9 +- ...clarationMergedInModuleWithContinuation.js | 9 +- .../classDeclaredBeforeClassFactory.js | 9 +- .../classDoesNotDependOnBaseTypes.js | 9 +- tests/baselines/reference/classExpression2.js | 9 +- tests/baselines/reference/classExpression3.js | 9 +- .../classExpressionExtendingAbstractClass.js | 9 +- ...lassExpressionInClassStaticDeclarations.js | 9 +- .../reference/classExtendingBuiltinType.js | 9 +- .../reference/classExtendingClass.js | 9 +- .../reference/classExtendingClassLikeType.js | 9 +- .../reference/classExtendingNonConstructor.js | 9 +- .../baselines/reference/classExtendingNull.js | 9 +- .../reference/classExtendingPrimitive.js | 9 +- .../reference/classExtendingPrimitive2.js | 9 +- .../reference/classExtendingQualifiedName.js | 9 +- .../reference/classExtendingQualifiedName2.js | 9 +- .../reference/classExtendsAcrossFiles.js | 18 +- ...sMergedWithModuleNotReferingConstructor.js | 9 +- ...tendsClauseClassNotReferringConstructor.js | 9 +- .../reference/classExtendsEveryObjectType.js | 9 +- .../reference/classExtendsEveryObjectType2.js | 9 +- .../reference/classExtendsInterface.js | 9 +- .../classExtendsInterfaceInExpression.js | 9 +- .../classExtendsInterfaceInModule.js | 9 +- .../reference/classExtendsInterface_not.js | 9 +- .../baselines/reference/classExtendsItself.js | 9 +- .../reference/classExtendsItselfIndirectly.js | 9 +- .../classExtendsItselfIndirectly2.js | 9 +- .../classExtendsItselfIndirectly3.js | 54 +- .../classExtendsMultipleBaseClasses.js | 9 +- tests/baselines/reference/classExtendsNull.js | 9 +- ...classExtendsShadowedConstructorFunction.js | 9 +- .../classExtendsValidConstructorFunction.js | 9 +- .../reference/classExtensionNameOutput.js | 9 +- .../classHeritageWithTrailingSeparator.js | 9 +- .../reference/classImplementsClass2.js | 9 +- .../reference/classImplementsClass3.js | 9 +- .../reference/classImplementsClass4.js | 9 +- .../reference/classImplementsClass5.js | 9 +- .../reference/classImplementsClass6.js | 9 +- tests/baselines/reference/classIndexer3.js | 9 +- tests/baselines/reference/classInheritence.js | 9 +- .../reference/classIsSubtypeOfBaseType.js | 9 +- ...MergedWithInterfaceMultipleBasesNoError.js | 9 +- tests/baselines/reference/classOrder2.js | 9 +- tests/baselines/reference/classOrderBug.js | 9 +- .../reference/classSideInheritance1.js | 9 +- .../reference/classSideInheritance2.js | 9 +- .../reference/classSideInheritance3.js | 9 +- tests/baselines/reference/classUpdateTests.js | 9 +- .../classWithBaseClassButNoConstructor.js | 9 +- .../reference/classWithConstructors.js | 9 +- .../reference/classWithProtectedProperty.js | 9 +- .../reference/classWithStaticMembers.js | 9 +- tests/baselines/reference/classdecl.js | 9 +- .../reference/cloduleGenericOnSelfMember.js | 9 +- .../reference/clodulesDerivedClasses.js | 9 +- ...llisionSuperAndLocalFunctionInAccessors.js | 9 +- ...isionSuperAndLocalFunctionInConstructor.js | 9 +- .../collisionSuperAndLocalFunctionInMethod.js | 9 +- ...ollisionSuperAndLocalFunctionInProperty.js | 9 +- .../collisionSuperAndLocalVarInAccessors.js | 9 +- .../collisionSuperAndLocalVarInConstructor.js | 9 +- .../collisionSuperAndLocalVarInMethod.js | 9 +- .../collisionSuperAndLocalVarInProperty.js | 9 +- .../collisionSuperAndNameResolution.js | 9 +- .../reference/collisionSuperAndParameter.js | 9 +- .../reference/collisionSuperAndParameter1.js | 9 +- ...perAndPropertyNameAsConstuctorParameter.js | 9 +- ...xpressionAndLocalVarWithSuperExperssion.js | 9 +- .../reference/commentsInheritance.js | 9 +- .../comparisonOperatorWithIdenticalObjects.js | 9 +- ...ithNoRelationshipObjectsOnCallSignature.js | 9 +- ...lationshipObjectsOnConstructorSignature.js | 9 +- ...thNoRelationshipObjectsOnIndexSignature.js | 9 +- ...nshipObjectsOnInstantiatedCallSignature.js | 9 +- ...jectsOnInstantiatedConstructorSignature.js | 9 +- ...peratorWithSubtypeObjectOnCallSignature.js | 9 +- ...WithSubtypeObjectOnConstructorSignature.js | 9 +- ...eratorWithSubtypeObjectOnIndexSignature.js | 9 +- ...ubtypeObjectOnInstantiatedCallSignature.js | 9 +- ...bjectOnInstantiatedConstructorSignature.js | 9 +- ...isonOperatorWithSubtypeObjectOnProperty.js | 9 +- .../reference/complexClassRelationships.js | 9 +- ...catedGenericRecursiveBaseClassReference.js | 9 +- .../reference/compoundAssignmentLHSIsValue.js | 9 +- ...poundExponentiationAssignmentLHSIsValue.js | 9 +- .../reference/computedPropertyNames24_ES5.js | 9 +- .../reference/computedPropertyNames25_ES5.js | 9 +- .../reference/computedPropertyNames26_ES5.js | 9 +- .../reference/computedPropertyNames27_ES5.js | 9 +- .../reference/computedPropertyNames28_ES5.js | 9 +- .../reference/computedPropertyNames30_ES5.js | 9 +- .../reference/computedPropertyNames31_ES5.js | 9 +- .../reference/computedPropertyNames43_ES5.js | 9 +- .../reference/computedPropertyNames44_ES5.js | 9 +- .../reference/computedPropertyNames45_ES5.js | 9 +- .../conditionalOperatorWithIdenticalBCT.js | 9 +- .../conditionalOperatorWithoutIdenticalBCT.js | 9 +- .../reference/constantOverloadFunction.js | 9 +- .../constantOverloadFunctionNoSubtypeError.js | 9 +- ...nstraintCheckInGenericBaseTypeReference.js | 9 +- ...uctSignatureAssignabilityInInheritance2.js | 9 +- ...uctSignatureAssignabilityInInheritance3.js | 9 +- ...uctSignatureAssignabilityInInheritance4.js | 9 +- ...uctSignatureAssignabilityInInheritance5.js | 9 +- ...uctSignatureAssignabilityInInheritance6.js | 9 +- tests/baselines/reference/constructorArgs.js | 9 +- ...uctorFunctionTypeIsAssignableToBaseType.js | 9 +- ...ctorFunctionTypeIsAssignableToBaseType2.js | 9 +- .../constructorHasPrototypeProperty.js | 9 +- .../reference/constructorOverloads2.js | 9 +- .../reference/constructorOverloads3.js | 9 +- .../reference/constructorWithCapturedSuper.js | 9 +- ...constructorWithIncompleteTypeAnnotation.js | 9 +- .../contextualTypeObjectSpreadExpression.js | 17 +- .../contextualTypingArrayOfLambdas.js | 9 +- ...contextualTypingOfConditionalExpression.js | 9 +- ...ontextualTypingOfConditionalExpression2.js | 9 +- .../controlFlowSuperPropertyAccess.js | 9 +- ...urcePropertyIsRelatableToTargetProperty.js | 9 +- .../reference/declFileClassExtendsNull.js | 9 +- .../declFileForFunctionTypeAsTypeParameter.js | 9 +- ...ileGenericClassWithGenericExtendedClass.js | 9 +- .../reference/declFileGenericType.js | 9 +- .../reference/declFileGenericType2.js | 9 +- ...lictingWithClassReferredByExtendsClause.js | 9 +- ...dsClauseThatHasItsContainerNameConflict.js | 9 +- .../declarationEmitExpressionInExtends.js | 9 +- .../declarationEmitExpressionInExtends2.js | 9 +- .../declarationEmitExpressionInExtends3.js | 9 +- .../declarationEmitExpressionInExtends4.js | 9 +- .../declarationEmitExpressionInExtends5.js | 9 +- ...clarationEmitLocalClassDeclarationMixin.js | 9 +- .../declarationEmitNameConflicts3.js | 9 +- .../declarationEmitPrivateNameCausesError.js | 9 +- ...tPrivateSymbolCausesVarDeclarationEmit2.js | 9 +- .../declarationEmitProtectedMembers.js | 9 +- .../declarationEmitThisPredicates01.js | 9 +- ...tionEmitThisPredicatesWithPrivateName01.js | 9 +- .../declarationNoDanglingGenerics.js | 9 +- .../reference/declareDottedExtend.js | 9 +- .../baselines/reference/decoratorOnClass9.js | 9 +- .../reference/decoratorOnClassConstructor2.js | 9 +- .../reference/decoratorOnClassConstructor3.js | 9 +- .../reference/decoratorOnClassConstructor4.js | 9 +- .../reference/decoratorOnClassMethod12.js | 9 +- .../defaultPropsEmptyCurlyBecomesAnyForJs.js | 18 +- ...edClassConstructorWithExplicitReturns01.js | 9 +- ...assConstructorWithExplicitReturns01.js.map | 2 +- ...tructorWithExplicitReturns01.sourcemap.txt | 245 +++--- ...derivedClassConstructorWithoutSuperCall.js | 9 +- ...ClassFunctionOverridesBaseClassAccessor.js | 9 +- .../derivedClassIncludesInheritedMembers.js | 9 +- ...idesIndexersWithAssignmentCompatibility.js | 9 +- .../derivedClassOverridesPrivateFunction1.js | 9 +- .../derivedClassOverridesPrivates.js | 9 +- .../derivedClassOverridesProtectedMembers.js | 9 +- .../derivedClassOverridesProtectedMembers2.js | 9 +- .../derivedClassOverridesProtectedMembers3.js | 9 +- .../derivedClassOverridesProtectedMembers4.js | 9 +- .../derivedClassOverridesPublicMembers.js | 9 +- .../derivedClassOverridesWithoutSubtype.js | 9 +- .../derivedClassParameterProperties.js | 9 +- ...dClassSuperCallsInNonConstructorMembers.js | 9 +- .../derivedClassSuperCallsWithThisArg.js | 9 +- .../reference/derivedClassTransitivity.js | 9 +- .../reference/derivedClassTransitivity2.js | 9 +- .../reference/derivedClassTransitivity3.js | 9 +- .../reference/derivedClassTransitivity4.js | 9 +- .../reference/derivedClassWithAny.js | 9 +- ...ivateInstanceShadowingProtectedInstance.js | 9 +- ...hPrivateInstanceShadowingPublicInstance.js | 9 +- ...thPrivateStaticShadowingProtectedStatic.js | 9 +- ...sWithPrivateStaticShadowingPublicStatic.js | 9 +- .../derivedClassWithoutExplicitConstructor.js | 9 +- ...derivedClassWithoutExplicitConstructor2.js | 9 +- ...derivedClassWithoutExplicitConstructor3.js | 9 +- tests/baselines/reference/derivedClasses.js | 9 +- .../reference/derivedGenericClassWithAny.js | 9 +- ...sesHiddenBaseCallViaSuperPropertyAccess.js | 9 +- .../derivedTypeDoesNotRequireExtendsClause.js | 9 +- .../destructuringParameterDeclaration5.js | 9 +- ...oubleMixinConditionalTypeBaseClassWorks.js | 9 +- .../emitBundleWithPrologueDirectives1.js | 9 +- .../reference/emitBundleWithShebang1.js | 9 +- .../reference/emitBundleWithShebang2.js | 9 +- ...BundleWithShebangAndPrologueDirectives1.js | 9 +- ...BundleWithShebangAndPrologueDirectives2.js | 9 +- ...tionWithPropertyAccessInHeritageClause1.js | 9 +- .../emitClassExpressionInDeclarationFile.js | 9 +- .../emitClassExpressionInDeclarationFile2.js | 9 +- ...BeforeEmitParameterPropertyDeclaration1.js | 9 +- ...SuperCallBeforeEmitPropertyDeclaration1.js | 9 +- ...arationAndParameterPropertyDeclaration1.js | 9 +- .../reference/emitThisInSuperMethodCall.js | 9 +- ...mitter.asyncGenerators.classMethods.es5.js | 9 +- tests/baselines/reference/emptyModuleName.js | 9 +- ...rorForwardReferenceForwadingConstructor.js | 9 +- tests/baselines/reference/errorSuperCalls.js | 9 +- .../reference/errorSuperPropertyAccess.js | 9 +- .../reference/errorsInGenericTypeReference.js | 9 +- .../reference/es6ClassSuperCodegenBug.js | 9 +- tests/baselines/reference/es6ClassTest.js | 9 +- tests/baselines/reference/es6ClassTest2.js | 9 +- tests/baselines/reference/es6ClassTest7.js | 9 +- .../excessPropertyCheckWithSpread.js | 17 +- .../excessPropertyCheckWithUnions.js | 17 +- ...xplicitAnyAfterSpreadNoImplicitAnyError.js | 17 +- .../exportAssignmentOfGenericType1.js | 9 +- .../exportClassExtendingIntersection.js | 18 +- .../exportDeclarationInInternalModule.js | 9 +- .../reference/exportDefaultAbstractClass.js | 18 +- tests/baselines/reference/extBaseClass1.js | 9 +- tests/baselines/reference/extBaseClass2.js | 9 +- .../extendAndImplementTheSameBaseType.js | 9 +- .../extendAndImplementTheSameBaseType2.js | 9 +- .../extendBaseClassBeforeItsDeclared.js | 9 +- .../extendClassExpressionFromModule.js | 9 +- .../extendConstructSignatureInInterface.js | 9 +- tests/baselines/reference/extendFromAny.js | 9 +- .../reference/extendNonClassSymbol1.js | 9 +- .../reference/extendNonClassSymbol2.js | 9 +- .../extendPrivateConstructorClass.js | 9 +- ...xtendingClassFromAliasAndUsageInIndexer.js | 18 +- .../reference/extendsClauseAlreadySeen.js | 9 +- .../reference/extendsClauseAlreadySeen2.js | 9 +- .../reference/extendsUntypedModule.js | 9 +- tests/baselines/reference/fluentClasses.js | 9 +- tests/baselines/reference/for-inStatements.js | 9 +- .../reference/for-inStatementsInvalid.js | 9 +- .../forStatementsMultipleInvalidDecl.js | 9 +- .../reference/functionImplementationErrors.js | 9 +- .../reference/functionImplementations.js | 9 +- .../reference/functionSubtypingOfVarArgs.js | 9 +- .../reference/functionSubtypingOfVarArgs2.js | 9 +- .../reference/generatedContextualTyping.js | 9 +- .../genericBaseClassLiteralProperty.js | 9 +- .../genericBaseClassLiteralProperty2.js | 9 +- ...allWithConstraintsTypeArgumentInference.js | 9 +- .../genericCallWithObjectTypeArgs2.js | 9 +- ...icCallWithObjectTypeArgsAndConstraints2.js | 9 +- ...icCallWithObjectTypeArgsAndConstraints3.js | 9 +- .../genericCallbacksAndClassHierarchy.js | 9 +- .../genericClassExpressionInFunction.js | 9 +- ...sInheritsConstructorFromNonGenericClass.js | 9 +- ...cClassPropertyInheritanceSpecialization.js | 9 +- .../reference/genericClassStaticMethod.js | 9 +- tests/baselines/reference/genericClasses3.js | 9 +- ...genericConstraintOnExtendedBuiltinTypes.js | 9 +- ...enericConstraintOnExtendedBuiltinTypes2.js | 9 +- .../genericDerivedTypeWithSpecializedBase.js | 9 +- .../genericDerivedTypeWithSpecializedBase2.js | 9 +- .../genericInheritedDefaultConstructors.js | 9 +- .../reference/genericPrototypeProperty2.js | 9 +- .../reference/genericPrototypeProperty3.js | 9 +- ...ericRecursiveImplicitConstructorErrors2.js | 9 +- ...ericRecursiveImplicitConstructorErrors3.js | 9 +- .../reference/genericTypeAssertions2.js | 9 +- .../reference/genericTypeAssertions4.js | 9 +- .../reference/genericTypeAssertions6.js | 9 +- .../reference/genericTypeConstraints.js | 9 +- ...genericTypeReferenceWithoutTypeArgument.js | 9 +- ...enericTypeReferenceWithoutTypeArgument2.js | 9 +- .../genericWithIndexerOfTypeParameterType2.js | 9 +- .../reference/heterogeneousArrayLiterals.js | 9 +- .../reference/ifDoWhileStatements.js | 9 +- .../illegalSuperCallsInConstructor.js | 9 +- .../implementClausePrecedingExtends.js | 9 +- ...gAnInterfaceExtendingClassWithPrivates2.js | 9 +- ...AnInterfaceExtendingClassWithProtecteds.js | 9 +- .../baselines/reference/importAsBaseClass.js | 9 +- tests/baselines/reference/importHelpers.js | 9 +- .../baselines/reference/importHelpersInTsx.js | 17 +- .../reference/importHelpersNoHelpers.js | 9 +- .../reference/importHelpersNoModule.js | 9 +- .../reference/importNotElidedWhenNotFound.js | 9 +- .../reference/importShadowsGlobalName.js | 9 +- .../reference/importUsedInExtendsList1.js | 9 +- .../reference/indexedAccessRelation.js | 9 +- .../reference/indexedAccessTypeConstraints.js | 9 +- .../reference/indexerConstraints2.js | 9 +- .../reference/indirectSelfReference.js | 9 +- .../reference/indirectSelfReferenceGeneric.js | 9 +- .../infinitelyExpandingTypesNonGenericBase.js | 9 +- .../inheritFromGenericTypeParameter.js | 9 +- ...SameNamePrivatePropertiesFromSameOrigin.js | 9 +- tests/baselines/reference/inheritance.js | 9 +- tests/baselines/reference/inheritance1.js | 9 +- ...itanceGrandParentPrivateMemberCollision.js | 9 +- ...tPrivateMemberCollisionWithPublicMember.js | 9 +- ...tPublicMemberCollisionWithPrivateMember.js | 9 +- ...ritanceMemberAccessorOverridingAccessor.js | 9 +- ...heritanceMemberAccessorOverridingMethod.js | 9 +- ...ritanceMemberAccessorOverridingProperty.js | 9 +- ...inheritanceMemberFuncOverridingAccessor.js | 9 +- .../inheritanceMemberFuncOverridingMethod.js | 9 +- ...inheritanceMemberFuncOverridingProperty.js | 9 +- ...ritanceMemberPropertyOverridingAccessor.js | 9 +- ...heritanceMemberPropertyOverridingMethod.js | 9 +- ...ritanceMemberPropertyOverridingProperty.js | 9 +- .../inheritanceOfGenericConstructorMethod1.js | 9 +- .../inheritanceOfGenericConstructorMethod2.js | 9 +- ...ritanceStaticAccessorOverridingAccessor.js | 9 +- ...heritanceStaticAccessorOverridingMethod.js | 9 +- ...ritanceStaticAccessorOverridingProperty.js | 9 +- ...inheritanceStaticFuncOverridingAccessor.js | 9 +- ...eStaticFuncOverridingAccessorOfFuncType.js | 9 +- .../inheritanceStaticFuncOverridingMethod.js | 9 +- ...inheritanceStaticFuncOverridingProperty.js | 9 +- ...eStaticFuncOverridingPropertyOfFuncType.js | 9 +- ...taticFunctionOverridingInstanceProperty.js | 9 +- .../inheritanceStaticMembersCompatible.js | 9 +- .../inheritanceStaticMembersIncompatible.js | 9 +- ...ritanceStaticPropertyOverridingAccessor.js | 9 +- ...heritanceStaticPropertyOverridingMethod.js | 9 +- ...ritanceStaticPropertyOverridingProperty.js | 9 +- .../inheritedConstructorWithRestParams.js | 9 +- .../inheritedConstructorWithRestParams2.js | 9 +- .../inheritedModuleMembersForClodule.js | 9 +- .../reference/instanceOfAssignability.js | 9 +- ...nstancePropertiesInheritedIntoClassType.js | 9 +- .../reference/instanceSubtypeCheck2.js | 9 +- ...nstanceofWithStructurallyIdenticalTypes.js | 9 +- .../instantiatedReturnTypeContravariance.js | 9 +- .../reference/interfaceClassMerging.js | 9 +- .../reference/interfaceClassMerging2.js | 9 +- .../reference/interfaceExtendsClass1.js | 9 +- .../interfaceExtendsClassWithPrivate1.js | 9 +- .../interfaceExtendsClassWithPrivate2.js | 9 +- .../interfaceExtendsObjectIntersection.js | 9 +- ...nterfaceExtendsObjectIntersectionErrors.js | 9 +- .../reference/interfaceImplementation8.js | 9 +- .../invalidModuleWithStatementsOfEveryKind.js | 9 +- .../invalidMultipleVariableDeclarations.js | 9 +- .../reference/invalidReturnStatements.js | 9 +- .../isolatedModulesImportExportElision.js | 9 +- ...NoImplicitAnyNoCascadingReferenceErrors.js | 9 +- tests/baselines/reference/jsdocTypeTagCast.js | 9 +- .../reference/jsxCallbackWithDestructuring.js | 9 +- .../baselines/reference/jsxHasLiteralType.js | 9 +- .../baselines/reference/jsxInExtendsClause.js | 9 +- .../reference/jsxSpreadFirstUnionNoErrors.js | 17 +- tests/baselines/reference/jsxViaImport.2.js | 9 +- tests/baselines/reference/jsxViaImport.js | 9 +- .../reference/keyofAndIndexedAccess.js | 9 +- tests/baselines/reference/lambdaArgCrash.js | 9 +- tests/baselines/reference/lift.js | 9 +- tests/baselines/reference/localTypes1.js | 9 +- tests/baselines/reference/m7Bugs.js | 9 +- .../reference/mappedTypePartialConstraints.js | 9 +- .../reference/mergedDeclarations5.js | 9 +- .../reference/mergedDeclarations6.js | 9 +- .../mergedInheritedClassInterface.js | 9 +- .../mergedInterfacesWithInheritedPrivates2.js | 9 +- .../mergedInterfacesWithInheritedPrivates3.js | 9 +- .../missingPropertiesOfClassExpression.js | 9 +- .../reference/mixinAccessModifiers.js | 9 +- .../reference/mixinClassesAnnotated.js | 9 +- .../reference/mixinClassesAnonymous.js | 9 +- .../reference/mixinClassesMembers.js | 9 +- .../reference/mixinPrivateAndProtected.js | 9 +- .../reference/mixingApparentTypeOverrides.js | 9 +- tests/baselines/reference/moduleAsBaseType.js | 9 +- .../moduleImportedForTypeArgumentPosition.js | 9 +- .../baselines/reference/moduleNoneOutFile.js | 9 +- .../moduleWithStatementsOfEveryKind.js | 9 +- .../reference/multipleInheritance.js | 9 +- .../mutuallyRecursiveGenericBaseTypes2.js | 9 +- .../reference/mutuallyRecursiveInference.js | 9 +- tests/baselines/reference/newTarget.es5.js | 9 +- .../noImplicitAnyMissingGetAccessor.js | 9 +- .../noImplicitAnyMissingSetAccessor.js | 9 +- ...enericClassExtendingGenericClassWithAny.js | 9 +- ...cIndexerConstrainsPropertyDeclarations2.js | 9 +- .../reference/numericIndexerConstraint3.js | 9 +- .../reference/numericIndexerConstraint4.js | 9 +- .../reference/numericIndexerTyping2.js | 9 +- ...objectCreationOfElementAccessExpression.js | 9 +- .../objectLiteralFreshnessWithSpread.js | 17 +- .../reference/objectLiteralNormalization.js | 17 +- tests/baselines/reference/objectSpread.js | 17 +- .../reference/objectSpreadComputedProperty.js | 17 +- .../reference/objectSpreadIndexSignature.js | 17 +- .../reference/objectSpreadNegative.js | 17 +- .../reference/objectSpreadNegativeParse.js | 17 +- .../reference/objectSpreadStrictNull.js | 17 +- ...preadWithinMethodWithinObjectWithSpread.js | 17 +- ...objectTypeHidingMembersOfExtendedObject.js | 9 +- ...objectTypesIdentityWithNumericIndexers1.js | 9 +- ...objectTypesIdentityWithNumericIndexers2.js | 9 +- ...objectTypesIdentityWithNumericIndexers3.js | 9 +- .../objectTypesIdentityWithPrivates.js | 9 +- .../objectTypesIdentityWithPrivates2.js | 9 +- .../objectTypesIdentityWithPrivates3.js | 9 +- .../objectTypesIdentityWithStringIndexers.js | 9 +- .../objectTypesIdentityWithStringIndexers2.js | 9 +- .../optionalConstructorArgInSuper.js | 9 +- tests/baselines/reference/optionalMethods.js | 9 +- .../reference/optionalParamArgsTest.js | 9 +- .../reference/optionalParamInOverride.js | 9 +- .../reference/optionalParameterProperty.js | 9 +- .../baselines/reference/outModuleConcatAmd.js | 9 +- .../reference/outModuleConcatAmd.js.map | 2 +- .../outModuleConcatAmd.sourcemap.txt | 65 +- .../reference/outModuleConcatSystem.js | 9 +- .../reference/outModuleConcatSystem.js.map | 2 +- .../outModuleConcatSystem.sourcemap.txt | 65 +- .../reference/outModuleTripleSlashRefs.js | 9 +- .../reference/outModuleTripleSlashRefs.js.map | 2 +- .../outModuleTripleSlashRefs.sourcemap.txt | 93 +-- tests/baselines/reference/overload1.js | 9 +- .../overloadOnConstConstraintChecks1.js | 9 +- .../overloadOnConstConstraintChecks2.js | 9 +- .../overloadOnConstConstraintChecks3.js | 9 +- .../overloadOnConstConstraintChecks4.js | 9 +- .../overloadOnConstantsInvalidOverload1.js | 9 +- .../baselines/reference/overloadResolution.js | 9 +- .../overloadResolutionClassConstructors.js | 9 +- .../overloadResolutionConstructors.js | 9 +- .../reference/overloadingOnConstants1.js | 9 +- .../reference/overloadingOnConstants2.js | 9 +- .../overrideBaseIntersectionMethod.js | 9 +- .../overridingPrivateStaticMembers.js | 9 +- .../reference/parseErrorInHeritageClause1.js | 9 +- tests/baselines/reference/parser509630.js | 9 +- tests/baselines/reference/parserAstSpans1.js | 9 +- .../reference/parserClassDeclaration1.js | 9 +- .../reference/parserClassDeclaration3.js | 9 +- .../reference/parserClassDeclaration4.js | 9 +- .../reference/parserClassDeclaration5.js | 9 +- .../reference/parserClassDeclaration6.js | 9 +- ...rrorRecovery_ExtendsOrImplementsClause2.js | 9 +- ...rrorRecovery_ExtendsOrImplementsClause4.js | 9 +- ...rrorRecovery_ExtendsOrImplementsClause5.js | 9 +- .../parserGenericsInTypeContexts1.js | 9 +- .../parserGenericsInTypeContexts2.js | 9 +- .../baselines/reference/parserRealSource10.js | 9 +- .../baselines/reference/parserRealSource11.js | 9 +- tests/baselines/reference/parserharness.js | 9 +- ...artiallyAnnotatedFunctionInferenceError.js | 9 +- ...tatedFunctionInferenceWithTypeParameter.js | 9 +- tests/baselines/reference/primitiveMembers.js | 9 +- tests/baselines/reference/privacyClass.js | 9 +- .../privacyClassExtendsClauseDeclFile.js | 18 +- tests/baselines/reference/privacyGloClass.js | 9 +- .../reference/privateAccessInSubclass1.js | 9 +- .../privateInstanceMemberAccessibility.js | 9 +- ...tedMembersAreNotAccessibleDestructuring.js | 9 +- .../privateStaticMemberAccessibility.js | 9 +- .../privateStaticNotAccessibleInClodule2.js | 9 +- .../amd/testGlo.js | 9 +- .../node/testGlo.js | 9 +- .../reference/project/prologueEmit/amd/out.js | 9 +- .../project/prologueEmit/node/out.js | 9 +- .../amd/m'ain.js | 9 +- .../node/m'ain.js | 9 +- .../reference/propertiesAndIndexers.js | 9 +- tests/baselines/reference/propertyAccess.js | 9 +- ...tyAccessOnTypeParameterWithConstraints2.js | 9 +- ...tyAccessOnTypeParameterWithConstraints3.js | 9 +- ...tyAccessOnTypeParameterWithConstraints5.js | 9 +- .../reference/propertyOverridingPrototype.js | 9 +- ...sPropertyAccessibleWithinNestedSubclass.js | 9 +- ...PropertyAccessibleWithinNestedSubclass1.js | 9 +- ...edClassPropertyAccessibleWithinSubclass.js | 9 +- ...dClassPropertyAccessibleWithinSubclass2.js | 9 +- ...dClassPropertyAccessibleWithinSubclass3.js | 9 +- .../protectedInstanceMemberAccessibility.js | 9 +- tests/baselines/reference/protectedMembers.js | 9 +- ...icClassPropertyAccessibleWithinSubclass.js | 9 +- ...cClassPropertyAccessibleWithinSubclass2.js | 9 +- ...solution-does-not-affect-class-heritage.js | 9 +- .../reference/reactNamespaceJSXEmit.js | 17 +- .../readonlyConstructorAssignment.js | 9 +- .../reference/recursiveBaseCheck3.js | 9 +- .../reference/recursiveBaseCheck4.js | 9 +- .../reference/recursiveBaseCheck6.js | 9 +- .../recursiveBaseConstructorCreation1.js | 9 +- ...ssInstantiationsWithDefaultConstructors.js | 9 +- .../reference/recursiveClassReferenceTest.js | 9 +- .../recursiveClassReferenceTest.js.map | 2 +- .../recursiveClassReferenceTest.sourcemap.txt | 751 +++++++++--------- .../reference/recursiveComplicatedClasses.js | 9 +- ...sivelySpecializedConstructorDeclaration.js | 9 +- .../reference/reexportClassDefinition.js | 9 +- .../reference/reexportDefaultIsCallable.js | 9 +- .../reference/reexportedMissingAlias.js | 9 +- ...lassDeclarationWhenInBaseTypeResolution.js | 9 +- .../reference/returnInConstructor1.js | 9 +- tests/baselines/reference/returnStatements.js | 9 +- ...peCheckExtendedClassInsidePublicMethod2.js | 9 +- ...peCheckExtendedClassInsideStaticMethod1.js | 9 +- tests/baselines/reference/scopeTests.js | 9 +- .../reference/shadowPrivateMembers.js | 9 +- ...sWithDefaultConstructorAndExtendsClause.js | 9 +- ...hDefaultConstructorAndExtendsClause.js.map | 2 +- ...tConstructorAndExtendsClause.sourcemap.txt | 81 +- .../specializedInheritedConstructors1.js | 9 +- .../specializedOverloadWithRestParameters.js | 9 +- .../spreadContextualTypedBindingPattern.js | 17 +- .../baselines/reference/spreadIntersection.js | 17 +- .../reference/spreadIntersectionJsx.js | 17 +- .../reference/spreadInvalidArgumentType.js | 17 +- tests/baselines/reference/spreadMethods.js | 17 +- .../baselines/reference/spreadNonPrimitive.js | 17 +- .../reference/spreadTypeRemovesReadonly.js | 17 +- tests/baselines/reference/spreadUnion.js | 17 +- tests/baselines/reference/spreadUnion2.js | 17 +- tests/baselines/reference/spreadUnion3.js | 17 +- tests/baselines/reference/staticFactory1.js | 9 +- .../baselines/reference/staticInheritance.js | 9 +- .../staticMemberAccessOffDerivedType1.js | 9 +- tests/baselines/reference/staticPropSuper.js | 9 +- .../reference/strictModeInConstructor.js | 9 +- .../reference/strictModeReservedWord.js | 9 +- ...trictModeReservedWordInClassDeclaration.js | 9 +- ...gIndexerConstrainsPropertyDeclarations2.js | 9 +- ...ubSubClassCanAccessProtectedConstructor.js | 9 +- .../reference/subtypesOfTypeParameter.js | 9 +- .../subtypesOfTypeParameterWithConstraints.js | 9 +- ...subtypesOfTypeParameterWithConstraints4.js | 9 +- ...OfTypeParameterWithRecursiveConstraints.js | 9 +- .../reference/subtypingTransitivity.js | 9 +- .../reference/subtypingWithCallSignatures2.js | 9 +- .../reference/subtypingWithCallSignatures3.js | 9 +- .../reference/subtypingWithCallSignatures4.js | 9 +- .../subtypingWithConstructSignatures2.js | 9 +- .../subtypingWithConstructSignatures3.js | 9 +- .../subtypingWithConstructSignatures4.js | 9 +- .../subtypingWithConstructSignatures5.js | 9 +- .../subtypingWithConstructSignatures6.js | 9 +- .../reference/subtypingWithNumericIndexer.js | 9 +- .../reference/subtypingWithNumericIndexer3.js | 9 +- .../reference/subtypingWithNumericIndexer4.js | 9 +- .../reference/subtypingWithObjectMembers.js | 9 +- .../reference/subtypingWithObjectMembers4.js | 9 +- ...subtypingWithObjectMembersAccessibility.js | 9 +- ...ubtypingWithObjectMembersAccessibility2.js | 9 +- .../reference/subtypingWithStringIndexer.js | 9 +- .../reference/subtypingWithStringIndexer3.js | 9 +- .../reference/subtypingWithStringIndexer4.js | 9 +- tests/baselines/reference/super.js | 9 +- tests/baselines/reference/super1.js | 9 +- tests/baselines/reference/super2.js | 9 +- tests/baselines/reference/superAccess.js | 9 +- tests/baselines/reference/superAccess2.js | 9 +- .../reference/superAccessCastedCall.js | 9 +- .../reference/superAccessInFatArrow1.js | 9 +- .../reference/superCallArgsMustMatch.js | 9 +- .../reference/superCallAssignResult.js | 9 +- .../superCallBeforeThisAccessing1.js | 9 +- .../superCallBeforeThisAccessing2.js | 9 +- .../superCallBeforeThisAccessing3.js | 9 +- .../superCallBeforeThisAccessing4.js | 9 +- .../superCallBeforeThisAccessing5.js | 9 +- .../superCallBeforeThisAccessing6.js | 9 +- .../superCallBeforeThisAccessing7.js | 9 +- .../superCallBeforeThisAccessing8.js | 9 +- ...allFromClassThatDerivesFromGenericType1.js | 9 +- ...allFromClassThatDerivesFromGenericType2.js | 9 +- ...eButWithIncorrectNumberOfTypeArguments1.js | 9 +- ...sFromGenericTypeButWithNoTypeArguments1.js | 9 +- ...ivesNonGenericTypeButWithTypeArguments1.js | 9 +- .../reference/superCallInNonStaticMethod.js | 9 +- .../reference/superCallInStaticMethod.js | 9 +- .../superCallInsideClassDeclaration.js | 9 +- .../superCallInsideClassExpression.js | 9 +- .../superCallInsideObjectLiteralExpression.js | 9 +- .../reference/superCallOutsideConstructor.js | 9 +- .../superCallParameterContextualTyping1.js | 9 +- .../superCallParameterContextualTyping2.js | 9 +- .../superCallParameterContextualTyping3.js | 9 +- .../reference/superCallWithCommentEmit01.js | 9 +- .../superCallWithMissingBaseClass.js | 9 +- tests/baselines/reference/superCalls.js | 9 +- .../reference/superCallsInConstructor.js | 9 +- .../baselines/reference/superElementAccess.js | 9 +- tests/baselines/reference/superErrors.js | 9 +- .../superHasMethodsFromMergedInterface.js | 9 +- .../baselines/reference/superInCatchBlock1.js | 9 +- .../reference/superInConstructorParam1.js | 9 +- tests/baselines/reference/superInLambdas.js | 9 +- .../reference/superInObjectLiterals_ES5.js | 9 +- tests/baselines/reference/superNewCall1.js | 9 +- .../reference/superNoModifiersCrash.js | 9 +- .../reference/superPropertyAccess.js | 9 +- .../reference/superPropertyAccess1.js | 9 +- .../reference/superPropertyAccess2.js | 9 +- ...essInComputedPropertiesOfNestedType_ES5.js | 9 +- .../superPropertyAccessInSuperCall01.js | 9 +- .../reference/superPropertyAccessNoError.js | 9 +- .../reference/superPropertyAccess_ES5.js | 9 +- ...opertyElementNoUnusedLexicalThisCapture.js | 9 +- ...perPropertyInConstructorBeforeSuperCall.js | 9 +- .../reference/superSymbolIndexedAccess5.js | 9 +- .../reference/superSymbolIndexedAccess6.js | 9 +- .../superWithGenericSpecialization.js | 9 +- .../baselines/reference/superWithGenerics.js | 9 +- .../reference/superWithTypeArgument.js | 9 +- .../reference/superWithTypeArgument2.js | 9 +- .../reference/superWithTypeArgument3.js | 9 +- ...side-object-literal-getters-and-setters.js | 9 +- tests/baselines/reference/switchStatements.js | 9 +- .../reference/systemModuleWithSuperClass.js | 9 +- .../reference/targetTypeBaseCalls.js | 9 +- .../reference/thisInInvalidContexts.js | 9 +- .../thisInInvalidContextsExternalModule.js | 9 +- tests/baselines/reference/thisInSuperCall.js | 9 +- tests/baselines/reference/thisInSuperCall1.js | 9 +- tests/baselines/reference/thisInSuperCall2.js | 9 +- tests/baselines/reference/thisInSuperCall3.js | 9 +- .../reference/thisTypeInFunctions.js | 9 +- .../reference/thisTypeInFunctions3.js | 9 +- .../reference/thisTypeInFunctionsNegative.js | 9 +- .../reference/tsxAttributeResolution15.js | 9 +- .../reference/tsxAttributeResolution16.js | 9 +- .../tsxCorrectlyParseLessThanComparison1.js | 9 +- .../tsxDefaultAttributesResolution1.js | 9 +- .../tsxDefaultAttributesResolution2.js | 9 +- .../tsxDefaultAttributesResolution3.js | 9 +- .../baselines/reference/tsxDynamicTagName5.js | 9 +- .../baselines/reference/tsxDynamicTagName7.js | 9 +- .../baselines/reference/tsxDynamicTagName8.js | 9 +- .../baselines/reference/tsxDynamicTagName9.js | 9 +- .../reference/tsxExternalModuleEmit1.js | 18 +- .../reference/tsxExternalModuleEmit2.js | 17 +- .../reference/tsxFragmentChildrenCheck.js | 9 +- .../reference/tsxGenericAttributesType3.js | 9 +- .../reference/tsxGenericAttributesType4.js | 9 +- .../reference/tsxGenericAttributesType5.js | 9 +- .../reference/tsxGenericAttributesType6.js | 9 +- .../reference/tsxGenericAttributesType9.js | 9 +- tests/baselines/reference/tsxReactEmit2.js | 17 +- tests/baselines/reference/tsxReactEmit4.js | 17 +- tests/baselines/reference/tsxReactEmit5.js | 17 +- tests/baselines/reference/tsxReactEmit6.js | 17 +- .../tsxSpreadAttributesResolution1.js | 9 +- .../tsxSpreadAttributesResolution10.js | 9 +- .../tsxSpreadAttributesResolution11.js | 9 +- .../tsxSpreadAttributesResolution12.js | 9 +- .../tsxSpreadAttributesResolution17.js | 9 +- .../tsxSpreadAttributesResolution2.js | 9 +- .../tsxSpreadAttributesResolution3.js | 9 +- .../tsxSpreadAttributesResolution4.js | 9 +- .../tsxSpreadAttributesResolution5.js | 9 +- .../tsxSpreadAttributesResolution6.js | 9 +- .../tsxSpreadAttributesResolution7.js | 9 +- .../tsxSpreadAttributesResolution8.js | 9 +- .../tsxSpreadAttributesResolution9.js | 9 +- .../reference/tsxSpreadChildrenInvalidType.js | 17 +- .../tsxStatelessFunctionComponents2.js | 9 +- .../reference/tsxUnionElementType3.js | 9 +- .../reference/tsxUnionElementType4.js | 9 +- .../reference/tsxUnionTypeComponent1.js | 9 +- .../typeAliasFunctionTypeSharedSymbol.js | 9 +- tests/baselines/reference/typeAssertions.js | 9 +- .../baselines/reference/typeGuardFunction.js | 9 +- .../reference/typeGuardFunctionErrors.js | 9 +- .../reference/typeGuardFunctionGenerics.js | 9 +- .../reference/typeGuardFunctionOfFormThis.js | 9 +- .../typeGuardFunctionOfFormThisErrors.js | 9 +- .../reference/typeGuardOfFormInstanceOf.js | 9 +- .../reference/typeGuardOfFormIsType.js | 9 +- .../reference/typeGuardOfFormThisMember.js | 9 +- .../typeGuardOfFormThisMemberErrors.js | 9 +- tests/baselines/reference/typeMatch2.js | 9 +- tests/baselines/reference/typeOfSuperCall.js | 9 +- .../reference/typeParameterAsBaseClass.js | 9 +- .../reference/typeParameterAsBaseType.js | 9 +- .../reference/typeParameterExtendingUnion1.js | 9 +- .../reference/typeParameterExtendingUnion2.js | 9 +- .../baselines/reference/typeRelationships.js | 9 +- .../baselines/reference/typeValueConflict1.js | 9 +- .../baselines/reference/typeValueConflict2.js | 9 +- .../reference/typeVariableTypeGuards.js | 9 +- tests/baselines/reference/typeofClass2.js | 9 +- .../typesWithSpecializedCallSignatures.js | 9 +- ...typesWithSpecializedConstructSignatures.js | 9 +- tests/baselines/reference/undeclaredBase.js | 9 +- .../undefinedIsSubtypeOfEverything.js | 9 +- .../baselines/reference/underscoreMapFirst.js | 9 +- .../underscoreThisInDerivedClass01.js | 9 +- .../underscoreThisInDerivedClass02.js | 9 +- .../reference/unionTypeEquivalence.js | 9 +- .../reference/unionTypeFromArrayLiteral.js | 9 +- .../reference/unionTypesAssignability.js | 9 +- tests/baselines/reference/unknownSymbols1.js | 9 +- tests/baselines/reference/unknownType1.js | 17 +- .../reference/unspecializedConstraints.js | 9 +- ...untypedFunctionCallsWithTypeParameters1.js | 9 +- .../reference/unusedClassesinNamespace4.js | 9 +- .../unusedIdentifiersConsolidated1.js | 9 +- .../reference/unusedInvalidTypeArguments.js | 18 +- .../useBeforeDeclaration_superClass.js | 9 +- .../reference/validUseOfThisInSuper.js | 9 +- .../reference/varArgsOnConstructorTypes.js | 9 +- 807 files changed, 5646 insertions(+), 3204 deletions(-) diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 7cfd4fdc664..9bcc8e89f5a 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -4072,7 +4072,7 @@ namespace ts { priority: 0, text: ` var __extends = (this && this.__extends) || (function () { - function extendStatics(d, b) { + var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; diff --git a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js index 93708cd8b5e..e609e3d1e6c 100644 --- a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js +++ b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js @@ -22,9 +22,12 @@ module A { //// [ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js index ecadd1fb601..29416ab80b3 100644 --- a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js +++ b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js @@ -26,9 +26,12 @@ module A { //// [ExportClassWithInaccessibleTypeInTypeParameterConstraint.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/abstractClassInLocalScope.js b/tests/baselines/reference/abstractClassInLocalScope.js index f221245ece7..afcefadb705 100644 --- a/tests/baselines/reference/abstractClassInLocalScope.js +++ b/tests/baselines/reference/abstractClassInLocalScope.js @@ -9,9 +9,12 @@ //// [abstractClassInLocalScope.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js index 88aceb2dd78..ec27e0d91fd 100644 --- a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js +++ b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js @@ -9,9 +9,12 @@ //// [abstractClassInLocalScopeIsAbstract.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/abstractProperty.js b/tests/baselines/reference/abstractProperty.js index 396af46ae6d..ca9bf0c3742 100644 --- a/tests/baselines/reference/abstractProperty.js +++ b/tests/baselines/reference/abstractProperty.js @@ -23,9 +23,12 @@ class C extends B { //// [abstractProperty.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/abstractPropertyNegative.js b/tests/baselines/reference/abstractPropertyNegative.js index a95d4edbfb4..4db1f89ff0d 100644 --- a/tests/baselines/reference/abstractPropertyNegative.js +++ b/tests/baselines/reference/abstractPropertyNegative.js @@ -45,9 +45,12 @@ abstract class AbstractAccessorMismatch { //// [abstractPropertyNegative.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/accessOverriddenBaseClassMember1.js b/tests/baselines/reference/accessOverriddenBaseClassMember1.js index 30aedee17f1..3f290cc5369 100644 --- a/tests/baselines/reference/accessOverriddenBaseClassMember1.js +++ b/tests/baselines/reference/accessOverriddenBaseClassMember1.js @@ -17,9 +17,12 @@ class ColoredPoint extends Point { //// [accessOverriddenBaseClassMember1.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/accessors_spec_section-4.5_inference.js b/tests/baselines/reference/accessors_spec_section-4.5_inference.js index bda4035bb91..5ba098f7c2d 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_inference.js +++ b/tests/baselines/reference/accessors_spec_section-4.5_inference.js @@ -26,9 +26,12 @@ class LanguageSpec_section_4_5_inference { //// [accessors_spec_section-4.5_inference.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js index 605bafa4b4f..34d2bf2ff49 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js @@ -39,9 +39,12 @@ exports.Model = Model; //// [aliasUsage1_moduleA.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/aliasUsageInArray.js b/tests/baselines/reference/aliasUsageInArray.js index aab66957f3e..38535edd441 100644 --- a/tests/baselines/reference/aliasUsageInArray.js +++ b/tests/baselines/reference/aliasUsageInArray.js @@ -33,9 +33,12 @@ exports.Model = Model; //// [aliasUsageInArray_moduleA.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.js b/tests/baselines/reference/aliasUsageInFunctionExpression.js index 6855a8eea50..e573e530123 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.js +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.js @@ -32,9 +32,12 @@ exports.Model = Model; //// [aliasUsageInFunctionExpression_moduleA.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.js b/tests/baselines/reference/aliasUsageInGenericFunction.js index 46398d251e8..db3a85835c5 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.js +++ b/tests/baselines/reference/aliasUsageInGenericFunction.js @@ -36,9 +36,12 @@ exports.Model = Model; //// [aliasUsageInGenericFunction_moduleA.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.js b/tests/baselines/reference/aliasUsageInIndexerOfClass.js index 9591be38642..282db192221 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.js +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.js @@ -38,9 +38,12 @@ exports.Model = Model; //// [aliasUsageInIndexerOfClass_moduleA.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.js b/tests/baselines/reference/aliasUsageInObjectLiteral.js index 20096e09f3e..1c794441f5c 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.js +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.js @@ -33,9 +33,12 @@ exports.Model = Model; //// [aliasUsageInObjectLiteral_moduleA.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/aliasUsageInOrExpression.js b/tests/baselines/reference/aliasUsageInOrExpression.js index c05abd8fb72..75bc90302c5 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.js +++ b/tests/baselines/reference/aliasUsageInOrExpression.js @@ -36,9 +36,12 @@ exports.Model = Model; //// [aliasUsageInOrExpression_moduleA.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js index ee78e98f75d..1faf2b813f3 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js @@ -36,9 +36,12 @@ exports.Model = Model; //// [aliasUsageInTypeArgumentOfExtendsClause_moduleA.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } @@ -58,9 +61,12 @@ exports.VisualizationModel = VisualizationModel; //// [aliasUsageInTypeArgumentOfExtendsClause_main.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.js b/tests/baselines/reference/aliasUsageInVarAssignment.js index ef1953d2e6b..bf7871a27ac 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.js +++ b/tests/baselines/reference/aliasUsageInVarAssignment.js @@ -32,9 +32,12 @@ exports.Model = Model; //// [aliasUsageInVarAssignment_moduleA.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/ambiguousOverloadResolution.js b/tests/baselines/reference/ambiguousOverloadResolution.js index 059fb86e66c..6e00d7b2374 100644 --- a/tests/baselines/reference/ambiguousOverloadResolution.js +++ b/tests/baselines/reference/ambiguousOverloadResolution.js @@ -10,9 +10,12 @@ var t: number = f(x, x); // Not an error //// [ambiguousOverloadResolution.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.js b/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.js index 3f6ecf1ca36..9d95712af40 100644 --- a/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.js +++ b/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.js @@ -23,9 +23,12 @@ export function Configurable>(base: T): T { //// [dist.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/anonymousClassDeclarationDoesntPrintWithReadonly.js b/tests/baselines/reference/anonymousClassDeclarationDoesntPrintWithReadonly.js index 1ecab30597a..2b535bf45fd 100644 --- a/tests/baselines/reference/anonymousClassDeclarationDoesntPrintWithReadonly.js +++ b/tests/baselines/reference/anonymousClassDeclarationDoesntPrintWithReadonly.js @@ -10,9 +10,12 @@ export function y() { //// [anonymousClassDeclarationDoesntPrintWithReadonly.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/apparentTypeSubtyping.js b/tests/baselines/reference/apparentTypeSubtyping.js index ed5b58a12fb..6b153002813 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.js +++ b/tests/baselines/reference/apparentTypeSubtyping.js @@ -25,9 +25,12 @@ class Derived2 extends Base2 { // error because of the prototy // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/apparentTypeSupertype.js b/tests/baselines/reference/apparentTypeSupertype.js index a34f3dbe958..63e6345e5ba 100644 --- a/tests/baselines/reference/apparentTypeSupertype.js +++ b/tests/baselines/reference/apparentTypeSupertype.js @@ -15,9 +15,12 @@ class Derived extends Base { // error // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/arrayAssignmentTest1.js b/tests/baselines/reference/arrayAssignmentTest1.js index f04bf8e8509..cf848855e5d 100644 --- a/tests/baselines/reference/arrayAssignmentTest1.js +++ b/tests/baselines/reference/arrayAssignmentTest1.js @@ -87,9 +87,12 @@ arr_any = i1; // should be an error - is //// [arrayAssignmentTest1.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/arrayAssignmentTest2.js b/tests/baselines/reference/arrayAssignmentTest2.js index 001a2eb3126..81176c8284f 100644 --- a/tests/baselines/reference/arrayAssignmentTest2.js +++ b/tests/baselines/reference/arrayAssignmentTest2.js @@ -61,9 +61,12 @@ arr_any = i1; // should be an error - is //// [arrayAssignmentTest2.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/arrayBestCommonTypes.js b/tests/baselines/reference/arrayBestCommonTypes.js index cb425609754..c1251a50f38 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.js +++ b/tests/baselines/reference/arrayBestCommonTypes.js @@ -109,9 +109,12 @@ module NonEmptyTypes { //// [arrayBestCommonTypes.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/arrayLiteralTypeInference.js b/tests/baselines/reference/arrayLiteralTypeInference.js index eabffbb8a2e..41cb85f8008 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.js +++ b/tests/baselines/reference/arrayLiteralTypeInference.js @@ -53,9 +53,12 @@ var z3: { id: number }[] = //// [arrayLiteralTypeInference.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/arrayLiterals.js b/tests/baselines/reference/arrayLiterals.js index 77daabbe229..bdc11c99e69 100644 --- a/tests/baselines/reference/arrayLiterals.js +++ b/tests/baselines/reference/arrayLiterals.js @@ -39,9 +39,12 @@ var context4: Base[] = [new Derived1(), new Derived1()]; //// [arrayLiterals.js] // Empty array literal with no contextual type has type Undefined[] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js index e1a19867f7c..49d1d33c2e8 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js @@ -27,9 +27,12 @@ var as = [list, myDerivedList]; // List[] //// [arrayLiteralsWithRecursiveGenerics.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js index f056e96eaed..47abb0d6255 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js @@ -21,9 +21,12 @@ rrb = cra; // error: 'A' is not assignable to 'B' //// [arrayOfSubtypeIsAssignableToReadonlyArray.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/arrowFunctionContexts.js b/tests/baselines/reference/arrowFunctionContexts.js index 452348e7301..d32683f8ed8 100644 --- a/tests/baselines/reference/arrowFunctionContexts.js +++ b/tests/baselines/reference/arrowFunctionContexts.js @@ -97,9 +97,12 @@ var asserted2: any; //// [arrowFunctionContexts.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js index 7d4a52f0a95..2490b1ef9c8 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js @@ -102,9 +102,12 @@ b18 = a18; // ok //// [assignmentCompatWithCallSignatures3.js] // these are all permitted with the current rules, since we do not do contextual signature instantiation var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js index 90f3e8307fd..d1e898d3c6d 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js @@ -101,9 +101,12 @@ module Errors { //// [assignmentCompatWithCallSignatures4.js] // These are mostly permitted with the current loose rules. All ok unless otherwise noted. var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js index 4e8c11a7fbb..6eaacacf897 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js @@ -68,9 +68,12 @@ b18 = a18; // ok //// [assignmentCompatWithCallSignatures5.js] // checking assignment compat for function types. No errors in this file var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js index 34cbf0748f7..775d7886310 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js @@ -45,9 +45,12 @@ b16 = x.a16; //// [assignmentCompatWithCallSignatures6.js] // checking assignment compatibility relations for function types. All valid var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js index ed5cc0543ce..15ebdef5dad 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js @@ -102,9 +102,12 @@ b18 = a18; // ok //// [assignmentCompatWithConstructSignatures3.js] // checking assignment compatibility relations for function types. All of these are valid. var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js index dc8d6915d10..aa0ce793dce 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js @@ -101,9 +101,12 @@ module Errors { //// [assignmentCompatWithConstructSignatures4.js] // checking assignment compatibility relations for function types. var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js index 7b96bd54b5c..fbe0f53fa56 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js @@ -68,9 +68,12 @@ b18 = a18; // ok //// [assignmentCompatWithConstructSignatures5.js] // checking assignment compat for function types. All valid var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js index a1951dfcbbd..b476dd66420 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js @@ -45,9 +45,12 @@ b16 = x.a16; //// [assignmentCompatWithConstructSignatures6.js] // checking assignment compatibility relations for function types. All valid. var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js index 23719df9126..cbe47f21a95 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js @@ -46,9 +46,12 @@ module Generics { //// [assignmentCompatWithNumericIndexer.js] // Derived type indexer must be subtype of base type indexer var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js index 1270283351b..cc8dc2fb1b8 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js @@ -43,9 +43,12 @@ module Generics { //// [assignmentCompatWithNumericIndexer3.js] // Derived type indexer must be subtype of base type indexer var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js index 375b9ab3e05..46dfee1ed80 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js @@ -94,9 +94,12 @@ module WithBase { //// [assignmentCompatWithObjectMembers4.js] // members N and M of types S and T have the same name, same accessibility, same optionality, and N is not assignable M var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js index 299d1fea0df..c53936f696e 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js @@ -91,9 +91,12 @@ module SourceHasOptional { //// [assignmentCompatWithObjectMembersOptionality.js] // Derived member is not optional but base member is, should be ok var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js index 2b4d9fd462b..60793f2843f 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js @@ -94,9 +94,12 @@ module SourceHasOptional { // M is optional and S contains no property with the same name as M // N is optional and T contains no property with the same name as N var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.js b/tests/baselines/reference/assignmentCompatWithStringIndexer.js index e57d1e7bf2c..62b22fc0091 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.js @@ -56,9 +56,12 @@ module Generics { //// [assignmentCompatWithStringIndexer.js] // index signatures must be compatible in assignments var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/assignmentLHSIsValue.js b/tests/baselines/reference/assignmentLHSIsValue.js index bc129cb2ca2..1eacd789df1 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.js +++ b/tests/baselines/reference/assignmentLHSIsValue.js @@ -72,9 +72,12 @@ foo() = value; //// [assignmentLHSIsValue.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/asyncImportedPromise_es5.js b/tests/baselines/reference/asyncImportedPromise_es5.js index 8b56ebbd1fa..5aabc56c56a 100644 --- a/tests/baselines/reference/asyncImportedPromise_es5.js +++ b/tests/baselines/reference/asyncImportedPromise_es5.js @@ -12,9 +12,12 @@ class Test { //// [task.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/autolift4.js b/tests/baselines/reference/autolift4.js index 2e5b3b258c6..19d6cd43932 100644 --- a/tests/baselines/reference/autolift4.js +++ b/tests/baselines/reference/autolift4.js @@ -25,9 +25,12 @@ class Point3D extends Point { //// [autolift4.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/baseCheck.js b/tests/baselines/reference/baseCheck.js index 463a29e1fbe..e48c235a087 100644 --- a/tests/baselines/reference/baseCheck.js +++ b/tests/baselines/reference/baseCheck.js @@ -31,9 +31,12 @@ function f() { //// [baseCheck.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/baseClassImprovedMismatchErrors.js b/tests/baselines/reference/baseClassImprovedMismatchErrors.js index 296f9e6eb1c..def62c018bd 100644 --- a/tests/baselines/reference/baseClassImprovedMismatchErrors.js +++ b/tests/baselines/reference/baseClassImprovedMismatchErrors.js @@ -20,9 +20,12 @@ class DerivedInterface implements Base { //// [baseClassImprovedMismatchErrors.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/baseConstraintOfDecorator.js b/tests/baselines/reference/baseConstraintOfDecorator.js index dc6ebd7397e..198dcb3d7b9 100644 --- a/tests/baselines/reference/baseConstraintOfDecorator.js +++ b/tests/baselines/reference/baseConstraintOfDecorator.js @@ -12,9 +12,12 @@ export function classExtender(superClass: TFunction, _instanceModifie //// [baseConstraintOfDecorator.js] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/baseExpressionTypeParameters.js b/tests/baselines/reference/baseExpressionTypeParameters.js index a3a77cbc6e3..fd907be7e52 100644 --- a/tests/baselines/reference/baseExpressionTypeParameters.js +++ b/tests/baselines/reference/baseExpressionTypeParameters.js @@ -16,9 +16,12 @@ class Spec extends Gen {} //// [baseExpressionTypeParameters.js] // Repro from #17829 var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/baseIndexSignatureResolution.js b/tests/baselines/reference/baseIndexSignatureResolution.js index 4053e588e44..d5732b7f3d5 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.js +++ b/tests/baselines/reference/baseIndexSignatureResolution.js @@ -26,9 +26,12 @@ var z: Derived = b.foo(); //// [baseIndexSignatureResolution.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/baseTypeOrderChecking.js b/tests/baselines/reference/baseTypeOrderChecking.js index 1dd92d473c1..9e6800d376a 100644 --- a/tests/baselines/reference/baseTypeOrderChecking.js +++ b/tests/baselines/reference/baseTypeOrderChecking.js @@ -38,9 +38,12 @@ class Class4 extends Class3 //// [baseTypeOrderChecking.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js index 86be6bcf5c1..3f8e475504d 100644 --- a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js @@ -29,9 +29,12 @@ class C extends CBase { //// [baseTypeWrappingInstantiationChain.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/bases.js b/tests/baselines/reference/bases.js index cd1f7ba94a8..9ff19e7ae61 100644 --- a/tests/baselines/reference/bases.js +++ b/tests/baselines/reference/bases.js @@ -22,9 +22,12 @@ new C().y; //// [bases.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js index 128c9f6d430..1eaa060ce1f 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js @@ -30,9 +30,12 @@ function foo5(t: T, u: U): Object { // conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist) // no errors expected here var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js index 1a8d0d50114..77543b29fe8 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js @@ -28,9 +28,12 @@ function foo3(t: T, u: U) { // conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist) // these are errors var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.js b/tests/baselines/reference/bestCommonTypeOfTuple2.js index a9eeb1eaaa1..0dbea701fa3 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple2.js +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.js @@ -24,9 +24,12 @@ var e51 = t5[2]; // {} //// [bestCommonTypeOfTuple2.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js index 70d76baf5ba..6913975d757 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js @@ -72,9 +72,12 @@ interface I extends A { //// [callSignatureAssignabilityInInheritance2.js] // checking subtype relations for function types as it relates to contextual signature instantiation var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js index c86b0bd7e12..27112f8d3c3 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js @@ -117,9 +117,12 @@ module Errors { // checking subtype relations for function types as it relates to contextual signature instantiation // error cases var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js index 1fc4c80345a..0928f8ebc29 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js @@ -52,9 +52,12 @@ interface I extends A { //// [callSignatureAssignabilityInInheritance4.js] // checking subtype relations for function types as it relates to contextual signature instantiation var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js index 5a021653cd8..c04d5bcb2ab 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js @@ -52,9 +52,12 @@ interface I extends B { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithCallSignatures2 just with an extra level of indirection in the inheritance chain var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js index f814b36a59e..aa189c78f8f 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js @@ -55,9 +55,12 @@ interface I9 extends A { // same as subtypingWithCallSignatures4 but using class type parameters instead of generic signatures // all are errors var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/callWithSpread.js b/tests/baselines/reference/callWithSpread.js index 1b78ebeb8ec..423721645ad 100644 --- a/tests/baselines/reference/callWithSpread.js +++ b/tests/baselines/reference/callWithSpread.js @@ -60,9 +60,12 @@ class D extends C { //// [callWithSpread.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js index 9ded081269f..2b8eb4e62aa 100644 --- a/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js +++ b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js @@ -13,9 +13,12 @@ class B extends A { //// [captureSuperPropertyAccessInSuperCall01.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/captureThisInSuperCall.js b/tests/baselines/reference/captureThisInSuperCall.js index 0b277e348a4..9406feca945 100644 --- a/tests/baselines/reference/captureThisInSuperCall.js +++ b/tests/baselines/reference/captureThisInSuperCall.js @@ -10,9 +10,12 @@ class B extends A { //// [captureThisInSuperCall.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/castingTuple.js b/tests/baselines/reference/castingTuple.js index a94246a19b8..4bb4f5f788b 100644 --- a/tests/baselines/reference/castingTuple.js +++ b/tests/baselines/reference/castingTuple.js @@ -36,9 +36,12 @@ t4[2] = 10; //// [castingTuple.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/chainedAssignment3.js b/tests/baselines/reference/chainedAssignment3.js index c0c0fd8c49a..acb96e5b9cf 100644 --- a/tests/baselines/reference/chainedAssignment3.js +++ b/tests/baselines/reference/chainedAssignment3.js @@ -24,9 +24,12 @@ a = b = new A(); //// [chainedAssignment3.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js index b58ad2ed28f..8b272b582a4 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js @@ -21,9 +21,12 @@ class C extends B { //// [chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/checkForObjectTooStrict.js b/tests/baselines/reference/checkForObjectTooStrict.js index ebe87e3e108..d8a30eac762 100644 --- a/tests/baselines/reference/checkForObjectTooStrict.js +++ b/tests/baselines/reference/checkForObjectTooStrict.js @@ -33,9 +33,12 @@ class Baz extends Object { //// [checkForObjectTooStrict.js] var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/checkJsxChildrenProperty12.js b/tests/baselines/reference/checkJsxChildrenProperty12.js index ca685d558bf..5b1d1d1b794 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty12.js +++ b/tests/baselines/reference/checkJsxChildrenProperty12.js @@ -35,9 +35,12 @@ class InnerButton extends React.Component { //// [file.jsx] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/checkJsxChildrenProperty13.js b/tests/baselines/reference/checkJsxChildrenProperty13.js index 9848847c088..45ef75b88b1 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty13.js +++ b/tests/baselines/reference/checkJsxChildrenProperty13.js @@ -30,9 +30,12 @@ class InnerButton extends React.Component { //// [file.jsx] "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tests/baselines/reference/checkJsxChildrenProperty14.js b/tests/baselines/reference/checkJsxChildrenProperty14.js index 182b0f0a879..833bd43155e 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty14.js +++ b/tests/baselines/reference/checkJsxChildrenProperty14.js @@ -45,9 +45,12 @@ let k5 = <>