From 64f17c5a9870fc452be98256402177a68105c30e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 18 Nov 2016 07:48:12 -0800 Subject: [PATCH 001/167] Use a symbol for untyped modules to distinguish from unknownSymbol --- src/compiler/checker.ts | 16 ++++++----- src/compiler/utilities.ts | 4 +-- .../reference/extendsUntypedModule.errors.txt | 14 ++++++++++ .../reference/extendsUntypedModule.js | 27 +++++++++++++++++++ tests/cases/compiler/extendsUntypedModule.ts | 9 +++++++ tests/cases/fourslash/untypedModuleImport.ts | 2 +- 6 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 tests/baselines/reference/extendsUntypedModule.errors.txt create mode 100644 tests/baselines/reference/extendsUntypedModule.js create mode 100644 tests/cases/compiler/extendsUntypedModule.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3d25fc8bbbb..cf87755034e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1099,7 +1099,7 @@ namespace ts { const moduleSymbol = resolveExternalModuleName(node, (node.parent).moduleSpecifier); if (moduleSymbol) { - const exportDefaultSymbol = isShorthandAmbientModuleSymbol(moduleSymbol) ? + const exportDefaultSymbol = isUntypedOrShorthandAmbientModuleSymbol(moduleSymbol) ? moduleSymbol : moduleSymbol.exports["export="] ? getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : @@ -1175,7 +1175,7 @@ namespace ts { if (targetSymbol) { const name = specifier.propertyName || specifier.name; if (name.text) { - if (isShorthandAmbientModuleSymbol(moduleSymbol)) { + if (isUntypedOrShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } @@ -1427,15 +1427,19 @@ namespace ts { Debug.assert(!!moduleNotFoundError); const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleName, resolvedModule.resolvedFileName); + return undefined; } else if (compilerOptions.noImplicitAny && moduleNotFoundError) { error(errorNode, Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + return undefined; } - // Failed imports and untyped modules are both treated in an untyped manner; only difference is whether we give a diagnostic first. - return undefined; + // Unlike a failed import, an untyped module produces a dummy symbol. This is checked for by `isUntypedOrShorthandAmbientModuleSymbol`. + const untypedSymbol = createSymbol(SymbolFlags.ValueModule, `"${moduleName}"`); + untypedSymbol.exports = createMap(); + return untypedSymbol; } if (moduleNotFoundError) { @@ -3575,7 +3579,7 @@ namespace ts { function getTypeOfFuncClassEnumModule(symbol: Symbol): Type { const links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & SymbolFlags.Module && isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & SymbolFlags.Module && isUntypedOrShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -19610,7 +19614,7 @@ namespace ts { function moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean { let moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression); - if (!moduleSymbol || isShorthandAmbientModuleSymbol(moduleSymbol)) { + if (!moduleSymbol || isUntypedOrShorthandAmbientModuleSymbol(moduleSymbol)) { // If the module is not found or is shorthand, assume that it may export a value. return true; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 546416884f1..c6dfcebdc54 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -388,8 +388,8 @@ namespace ts { } /** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */ - export function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean { - return isShorthandAmbientModule(moduleSymbol.valueDeclaration); + export function isUntypedOrShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean { + return !moduleSymbol.valueDeclaration || isShorthandAmbientModule(moduleSymbol.valueDeclaration); } function isShorthandAmbientModule(node: Node): boolean { diff --git a/tests/baselines/reference/extendsUntypedModule.errors.txt b/tests/baselines/reference/extendsUntypedModule.errors.txt new file mode 100644 index 00000000000..9a1c4235352 --- /dev/null +++ b/tests/baselines/reference/extendsUntypedModule.errors.txt @@ -0,0 +1,14 @@ +/a.ts(2,17): error TS2507: Type 'any' is not a constructor function type. + + +==== /a.ts (1 errors) ==== + import Foo from "foo"; + class A extends Foo { } + ~~~ +!!! error TS2507: Type 'any' is not a constructor function type. + +==== /node_modules/foo/index.js (0 errors) ==== + // Test that extending an untyped module is an error, unlike extending unknownSymbol. + + This file is not read. + \ No newline at end of file diff --git a/tests/baselines/reference/extendsUntypedModule.js b/tests/baselines/reference/extendsUntypedModule.js new file mode 100644 index 00000000000..0804595c08e --- /dev/null +++ b/tests/baselines/reference/extendsUntypedModule.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/extendsUntypedModule.ts] //// + +//// [index.js] +// Test that extending an untyped module is an error, unlike extending unknownSymbol. + +This file is not read. + +//// [a.ts] +import Foo from "foo"; +class A extends Foo { } + + +//// [a.js] +"use strict"; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var foo_1 = require("foo"); +var A = (function (_super) { + __extends(A, _super); + function A() { + return _super.apply(this, arguments) || this; + } + return A; +}(foo_1["default"])); diff --git a/tests/cases/compiler/extendsUntypedModule.ts b/tests/cases/compiler/extendsUntypedModule.ts new file mode 100644 index 00000000000..8eaf6b3833a --- /dev/null +++ b/tests/cases/compiler/extendsUntypedModule.ts @@ -0,0 +1,9 @@ +// Test that extending an untyped module is an error, unlike extending unknownSymbol. +// @noImplicitReferences: true + +// @Filename: /node_modules/foo/index.js +This file is not read. + +// @Filename: /a.ts +import Foo from "foo"; +class A extends Foo { } diff --git a/tests/cases/fourslash/untypedModuleImport.ts b/tests/cases/fourslash/untypedModuleImport.ts index d128ad24ea3..3fd209d480d 100644 --- a/tests/cases/fourslash/untypedModuleImport.ts +++ b/tests/cases/fourslash/untypedModuleImport.ts @@ -13,7 +13,7 @@ verify.numberOfErrorsInCurrentFile(0); goTo.marker("fooModule"); verify.goToDefinitionIs([]); -verify.quickInfoIs(""); +verify.quickInfoIs('module "foo"'); verify.referencesAre([]) goTo.marker("foo"); From 4df4a2bbc7a1a71a440636f3bb18e5d9495569c8 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 25 Jan 2017 06:53:07 -0800 Subject: [PATCH 002/167] Use a single 'untypedModuleSymbol' for all untyped modules instead of creating a new one for each module. --- src/compiler/checker.ts | 10 ++++++---- .../baselines/reference/extendsUntypedModule.js | 17 +++++++++++------ tests/cases/fourslash/untypedModuleImport.ts | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 332031903db..224da5e69c2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -132,6 +132,8 @@ namespace ts { const evolvingArrayTypes: EvolvingArrayType[] = []; const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); + const untypedModuleSymbol = createSymbol(SymbolFlags.ValueModule, ""); + untypedModuleSymbol.exports = createMap(); const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); const anyType = createIntrinsicType(TypeFlags.Any, "any"); @@ -1490,10 +1492,10 @@ namespace ts { resolvedModule.resolvedFileName); return undefined; } - // Unlike a failed import, an untyped module produces a dummy symbol. This is checked for by `isUntypedOrShorthandAmbientModuleSymbol`. - const untypedSymbol = createSymbol(SymbolFlags.ValueModule, `"${moduleName}"`); - untypedSymbol.exports = createMap(); - return untypedSymbol; + // Unlike a failed import, an untyped module produces a dummy symbol. + // This is checked for by `isUntypedOrShorthandAmbientModuleSymbol`. + // This must be different than `unknownSymbol` because `getBaseConstructorTypeOfClass` won't fail for `unknownSymbol`. + return untypedModuleSymbol; } if (moduleNotFoundError) { diff --git a/tests/baselines/reference/extendsUntypedModule.js b/tests/baselines/reference/extendsUntypedModule.js index 0804595c08e..ad35e4abaac 100644 --- a/tests/baselines/reference/extendsUntypedModule.js +++ b/tests/baselines/reference/extendsUntypedModule.js @@ -12,16 +12,21 @@ class A extends Foo { } //// [a.js] "use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __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]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var foo_1 = require("foo"); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(foo_1["default"])); diff --git a/tests/cases/fourslash/untypedModuleImport.ts b/tests/cases/fourslash/untypedModuleImport.ts index c09f710177b..276277102b0 100644 --- a/tests/cases/fourslash/untypedModuleImport.ts +++ b/tests/cases/fourslash/untypedModuleImport.ts @@ -12,7 +12,7 @@ verify.numberOfErrorsInCurrentFile(0); goTo.marker("fooModule"); verify.goToDefinitionIs([]); -verify.quickInfoIs('module "foo"'); +verify.quickInfoIs('module '); verify.referencesAre([]) goTo.marker("foo"); From 91421c8dbc0dfa5c50e7219dab22abbd82c77d4f Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 10 Feb 2017 12:24:10 -0800 Subject: [PATCH 003/167] Fix "semicolon" lint rule options (was not enabled) --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 4 ++-- src/compiler/moduleNameResolver.ts | 2 +- src/compiler/transformers/es2015.ts | 2 +- src/harness/fourslash.ts | 4 ++-- src/harness/harness.ts | 2 +- src/harness/unittests/compileOnSave.ts | 2 +- src/harness/unittests/printer.ts | 2 +- src/harness/unittests/textStorage.ts | 2 +- src/harness/unittests/tsserverProjectSystem.ts | 10 +++++----- src/harness/unittests/typingsInstaller.ts | 4 ++-- src/server/editorServices.ts | 4 ++-- src/server/project.ts | 4 ++-- src/server/scriptInfo.ts | 2 +- src/server/server.ts | 4 ++-- src/server/typingsInstaller/nodeTypingsInstaller.ts | 4 +--- src/services/codefixes/importFixes.ts | 6 +++--- src/services/findAllReferences.ts | 4 ++-- tslint.json | 2 +- 19 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac1135788cd..cd06c3b577e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19760,7 +19760,7 @@ namespace ts { } if (potentialNewTargetCollisions.length) { - forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope) + forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); potentialNewTargetCollisions.length = 0; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 94e32dfdbb3..e75cd09170e 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -84,7 +84,7 @@ namespace ts { this.index++; return { value: this.selector(this.data, this.keys[index]), done: false }; } - return { value: undefined as never, done: true } + return { value: undefined as never, done: true }; } } @@ -140,7 +140,7 @@ namespace ts { action(this.data[key], key); } } - } + }; } export function createFileMap(keyMapper?: (key: string) => string): FileMap { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 0300ff71ec5..651c8b3897c 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -958,7 +958,7 @@ namespace ts { const result = cache && cache.get(containingDirectory); if (result) { if (traceEnabled) { - trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName) + trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index e0fd435a90d..9c11364ed3c 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -2581,7 +2581,7 @@ namespace ts { if (loopOutParameters.length) { copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements); } - addRange(statements, lexicalEnvironment) + addRange(statements, lexicalEnvironment); loopBody = createBlock(statements, /*multiline*/ true); } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index fc85fb7276c..5d63298b946 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -571,7 +571,7 @@ namespace FourSlash { } private getGoToDefinition(): ts.DefinitionInfo[] { - return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) + return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); } public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) { @@ -912,7 +912,7 @@ namespace FourSlash { function rangeToReferenceEntry(r: Range) { let { isWriteAccess, isDefinition } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false }; isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition; - return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition } + return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }; } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 1dd41f9d81c..f999c6a0081 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -44,7 +44,7 @@ declare namespace NodeJS { declare var window: {}; declare var XMLHttpRequest: { new(): XMLHttpRequest; -} +}; interface XMLHttpRequest { readonly readyState: number; readonly responseText: string; diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index c8deb9e7554..0c9390924ac 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -495,7 +495,7 @@ namespace ts.projectSystem { const emitOutput = host.readFile(path + ".js"); assert.equal(emitOutput, f.content + newLine, "content of emit output should be identical with the input + newline"); } - }) + }); it("should emit specified file", () => { const file1 = { diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index 2496a880bc5..1a5a5a12f9e 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -9,7 +9,7 @@ namespace ts { Harness.Baseline.runBaseline(`printerApi/${prefix}.${name}.js`, () => printCallback(createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed, ...options }))); }); - } + }; } describe("printFile", () => { diff --git a/src/harness/unittests/textStorage.ts b/src/harness/unittests/textStorage.ts index b4287f2610c..545d090df9b 100644 --- a/src/harness/unittests/textStorage.ts +++ b/src/harness/unittests/textStorage.ts @@ -65,6 +65,6 @@ namespace ts.textStorage { ts1.getLineInfo(0); assert.isTrue(ts1.hasScriptVersionCache(), "have script version cache - 2"); - }) + }); }); } \ No newline at end of file diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index e6f4abde382..228d6aa8f6e 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -600,7 +600,7 @@ namespace ts.projectSystem { checkProjectActualFiles(service.configuredProjects[0], []); checkProjectActualFiles(service.inferredProjects[0], [f1.path]); - }) + }); it("create configured project without file list", () => { const configFile: FileOrFolder = { @@ -1153,7 +1153,7 @@ namespace ts.projectSystem { const host = createServerHost([f1, f2, libFile]); const service = createProjectService(host); - service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} }) + service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} }); service.openClientFile(f1.path); service.openClientFile(f2.path, "let x: string"); @@ -1185,7 +1185,7 @@ namespace ts.projectSystem { const host = createServerHost([f1, f2, libFile]); const service = createProjectService(host); - service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} }) + service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} }); service.openClientFile(f1.path); service.openClientFile(f2.path, "let somelongname: string"); @@ -1868,7 +1868,7 @@ namespace ts.projectSystem { for (const f of [f2, f3]) { const scriptInfo = projectService.getScriptInfoForNormalizedPath(server.toNormalizedPath(f.path)); - assert.equal(scriptInfo.containingProjects.length, 0, `expect 0 containing projects for '${f.path}'`) + assert.equal(scriptInfo.containingProjects.length, 0, `expect 0 containing projects for '${f.path}'`); } }); @@ -1984,7 +1984,7 @@ namespace ts.projectSystem { projectFileName, rootFiles: [toExternalFile(f1.path)], options: {} - }) + }); projectService.openClientFile(f1.path, "let x = 1;\nlet y = 2;"); projectService.checkNumberOfProjects({ externalProjects: 1 }); diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 29076df80f2..2eae01c3520 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -56,7 +56,7 @@ namespace ts.projectSystem { path: "/a/config.js", content: "export let x = 1" }; - const typesCache = "/cache" + const typesCache = "/cache"; const typesConfig = { path: typesCache + "/node_modules/@types/config/index.d.ts", content: "export let y: number;" @@ -74,7 +74,7 @@ namespace ts.projectSystem { super(host, { typesRegistry: createTypesRegistry("config"), globalTypingsCacheLocation: typesCache }); } installWorker(_requestId: number, _args: string[], _cwd: string, _cb: server.typingsInstaller.RequestCompletedAction) { - assert(false, "should not be called") + assert(false, "should not be called"); } })(); const service = createProjectService(host, { typingsInstaller: installer }); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index edc4fab9a19..f0aaba3d5bc 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -140,7 +140,7 @@ namespace ts.server { getScriptKind: _ => undefined, hasMixedContent: (fileName, extraFileExtensions) => { const mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, item => item.isMixedContent), item => item.extension); - return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension)) + return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension)); } }; @@ -1377,7 +1377,7 @@ namespace ts.server { // close projects that were missing in the input list forEachKey(projectsToClose, externalProjectName => { - this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true) + this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true); }); this.refreshInferredProjects(); diff --git a/src/server/project.ts b/src/server/project.ts index 6042fd9a62b..4f218d39007 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -689,7 +689,7 @@ namespace ts.server { const fileName = resolvedTypeReferenceDirective.resolvedFileName; const typeFilePath = toPath(fileName, currentDirectory, getCanonicalFileName); referencedFiles.set(typeFilePath, true); - }) + }); } const allFileNames = arrayFrom(referencedFiles.keys()) as Path[]; @@ -711,7 +711,7 @@ namespace ts.server { const id = nextId; nextId++; return makeInferredProjectName(id); - } + }; })(); private _isJsInferredProject = false; diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index be3ef34ce3a..e5df91fd930 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -48,7 +48,7 @@ namespace ts.server { public reloadFromFile(tempFileName?: string) { if (this.svc || (tempFileName !== this.fileName)) { - this.reload(this.getFileText(tempFileName)) + this.reload(this.getFileText(tempFileName)); } else { this.setText(undefined); diff --git a/src/server/server.ts b/src/server/server.ts index e689a2fc782..989c3558848 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -46,14 +46,14 @@ namespace ts.server { if (process.env.XDG_CACHE_HOME) { return process.env.XDG_CACHE_HOME; } - const usersDir = platformIsDarwin ? "Users" : "home" + const usersDir = platformIsDarwin ? "Users" : "home"; const homePath = (os.homedir && os.homedir()) || process.env.HOME || ((process.env.LOGNAME || process.env.USER) && `/${usersDir}/${process.env.LOGNAME || process.env.USER}`) || os.tmpdir(); const cacheFolder = platformIsDarwin ? "Library/Caches" - : ".cache" + : ".cache"; return combinePaths(normalizeSlashes(homePath), cacheFolder); } diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index ff20e89e2d7..447a2c05429 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -61,9 +61,7 @@ namespace ts.server.typingsInstaller { return combinePaths(normalizeSlashes(globalTypingsCacheLocation), `node_modules/${TypesRegistryPackageName}/index.json`); } - type ExecSync = { - (command: string, options: { cwd: string, stdio?: "ignore" }): any - } + type ExecSync = (command: string, options: { cwd: string, stdio?: "ignore" }) => any; export class NodeTypingsInstaller extends TypingsInstaller { private readonly execSync: ExecSync; diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 1f1b499d03b..1c157257051 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -3,8 +3,8 @@ namespace ts.codefix { type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport"; interface ImportCodeAction extends CodeAction { - kind: ImportCodeActionKind, - moduleSpecifier?: string + kind: ImportCodeActionKind; + moduleSpecifier?: string; } enum ModuleSpecifierComparison { @@ -75,7 +75,7 @@ namespace ts.codefix { getAllActions() { let result: ImportCodeAction[] = []; for (const key in this.symbolIdToActionMap) { - result = concatenate(result, this.symbolIdToActionMap[key]) + result = concatenate(result, this.symbolIdToActionMap[key]); } return result; } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index cd1477c4448..610fa25d7be 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -414,7 +414,7 @@ namespace ts.FindAllReferences { name, textSpan: createTextSpan(0, 1), displayParts: [{ text: name, kind: ScriptElementKind.keyword }] - } + }; const references: ReferenceEntry[] = []; for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); @@ -610,7 +610,7 @@ namespace ts.FindAllReferences { const result: Node[] = []; for (const decl of classSymbol.members.get("__constructor").declarations) { - const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)! + const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)!; Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); result.push(ctrKeyword); } diff --git a/tslint.json b/tslint.json index 13de7acec63..3952d4fac29 100644 --- a/tslint.json +++ b/tslint.json @@ -17,7 +17,7 @@ "double", "avoid-escape" ], - "semicolon": [true, "ignore-bound-class-methods"], + "semicolon": [true, "always", "ignore-bound-class-methods"], "whitespace": [true, "check-branch", "check-decl", From 20cc428785b2e427b4689f303018683d921b5bbb Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Fri, 10 Feb 2017 19:24:56 -0800 Subject: [PATCH 004/167] Fix jsdoc typedef symbol scope + avoid bind twice if the tag has a jsdoc namespace --- .gitignore | 1 + src/compiler/binder.ts | 59 +++++++++++++++++++ .../fourslash/server/jsdocTypedefTag1.ts | 20 +++++++ .../fourslash/server/jsdocTypedefTag2.ts | 30 ++++++++++ 4 files changed, 110 insertions(+) create mode 100644 tests/cases/fourslash/server/jsdocTypedefTag1.ts create mode 100644 tests/cases/fourslash/server/jsdocTypedefTag2.ts diff --git a/.gitignore b/.gitignore index f1ea04e3efb..a6c8c2940d8 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,4 @@ internal/ !tests/cases/projects/NodeModulesSearch/**/* !tests/baselines/reference/project/nodeModules*/**/* .idea +yarn.lock \ No newline at end of file diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 04dc4011a15..446fadcc3b4 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -669,6 +669,12 @@ namespace ts { case SyntaxKind.CallExpression: bindCallExpressionFlow(node); break; + case SyntaxKind.JSDocComment: + bindJSDocComment(node); + break; + case SyntaxKind.JSDocTypedefTag: + bindJSDocTypedefTag(node); + break; default: bindEachChild(node); break; @@ -1298,6 +1304,26 @@ namespace ts { } } + function bindJSDocComment(node: JSDoc) { + forEachChild(node, n => { + if (n.kind !== SyntaxKind.JSDocTypedefTag) { + bind(n); + } + }); + } + + function bindJSDocTypedefTag(node: JSDocTypedefTag) { + forEachChild(node, n => { + // if the node has a fullName "A.B.C", that means symbol "C" was already bond + // when we visit "fullName"; so when we visit the name "C" as the next child of + // the jsDocTypedefTag, we should skip binding it. + if (n === node.name && node.fullName.kind !== SyntaxKind.Identifier) { + return; + } + bind(n); + }); + } + function bindCallExpressionFlow(node: CallExpression) { // If the target of the call expression is a function expression or arrow function we have // an immediately invoked function expression (IIFE). Initialize the flowNode property to @@ -1827,6 +1853,18 @@ namespace ts { } node.parent = parent; const saveInStrictMode = inStrictMode; + + // Even though in the AST the jsdoc @typedef node belongs to the current node, + // its symbol might be in the same scope with the current node's symbol. Consider: + // + // /** @typedef {string | number} MyType */ + // function foo(); + // + // Here the current node is "foo", which is a container, but the scope of "MyType" should + // not be inside "foo". Therefore we always bind @typedef before bind the parent node, + // and skip binding this tag later when binding all the other jsdoc tags. + bindJSDocTypedefTagIfAny(node); + // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: @@ -1861,6 +1899,27 @@ namespace ts { inStrictMode = saveInStrictMode; } + function bindJSDocTypedefTagIfAny(node: Node) { + if (!node.jsDoc) { + return; + } + + for (const jsDoc of node.jsDoc) { + if (!jsDoc.tags) { + continue; + } + + for (const tag of jsDoc.tags) { + if (tag.kind === SyntaxKind.JSDocTypedefTag) { + const savedParent = parent; + parent = jsDoc; + bind(tag); + parent = savedParent; + } + } + } + } + function updateStrictModeStatementList(statements: NodeArray) { if (!inStrictMode) { for (const statement of statements) { diff --git a/tests/cases/fourslash/server/jsdocTypedefTag1.ts b/tests/cases/fourslash/server/jsdocTypedefTag1.ts new file mode 100644 index 00000000000..273dc1002af --- /dev/null +++ b/tests/cases/fourslash/server/jsdocTypedefTag1.ts @@ -0,0 +1,20 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: jsdocCompletion_typedef.js + +//// /** +//// * @typedef {Object} MyType +//// * @property {string} yes +//// */ +//// function foo() { } + +//// /** +//// * @param {MyType} my +//// */ +//// function a(my) { +//// my.yes./*1*/ +//// } + +goTo.marker('1'); +verify.completionListContains('charAt'); \ No newline at end of file diff --git a/tests/cases/fourslash/server/jsdocTypedefTag2.ts b/tests/cases/fourslash/server/jsdocTypedefTag2.ts new file mode 100644 index 00000000000..60210935210 --- /dev/null +++ b/tests/cases/fourslash/server/jsdocTypedefTag2.ts @@ -0,0 +1,30 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: jsdocCompletion_typedef.js + +//// /** +//// * @typedef {Object} A.B.MyType +//// * @property {string} yes +//// */ +//// function foo() {} + +//// /** +//// * @param {A.B.MyType} my2 +//// */ +//// function a(my2) { +//// my2.yes./*1*/ +//// } + +//// /** +//// * @param {MyType} my2 +//// */ +//// function b(my2) { +//// my2.yes./*2*/ +//// } + + +goTo.marker('1'); +verify.completionListContains('charAt'); +goTo.marker('2'); +verify.not.completionListContains('charAt'); \ No newline at end of file From 1c080d11e6445398ff34b50995f5f9aa6acf2d1d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 20 Jan 2017 07:20:23 -0800 Subject: [PATCH 005/167] Set ScriptElementKind for enum members to "enum member" instead of "const" --- src/services/types.ts | 3 +-- tests/cases/fourslash/deleteClassWithEnumPresent.ts | 12 ++++++------ ...navigationBarItemsInsideMethodsAndConstructors.ts | 8 ++++---- tests/cases/fourslash/navigationBarItemsItems.ts | 12 ++++++------ tests/cases/fourslash/server/navbar01.ts | 12 ++++++------ 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/services/types.ts b/src/services/types.ts index b4210538518..e7e80cb1cc6 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -701,8 +701,7 @@ namespace ts { /** enum E */ export const enumElement = "enum"; - // TODO: GH#9983 - export const enumMemberElement = "const"; + export const enumMemberElement = "enum member"; /** * Inside module and script only diff --git a/tests/cases/fourslash/deleteClassWithEnumPresent.ts b/tests/cases/fourslash/deleteClassWithEnumPresent.ts index 8914e0020a0..aaa35272fa9 100644 --- a/tests/cases/fourslash/deleteClassWithEnumPresent.ts +++ b/tests/cases/fourslash/deleteClassWithEnumPresent.ts @@ -16,15 +16,15 @@ verify.navigationTree({ "childItems": [ { "text": "a", - "kind": "const" + "kind": "enum member" }, { "text": "b", - "kind": "const" + "kind": "enum member" }, { "text": "c", - "kind": "const" + "kind": "enum member" } ] } @@ -48,15 +48,15 @@ verify.navigationBar([ "childItems": [ { "text": "a", - "kind": "const" + "kind": "enum member" }, { "text": "b", - "kind": "const" + "kind": "enum member" }, { "text": "c", - "kind": "const" + "kind": "enum member" } ], "indent": 1 diff --git a/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts b/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts index 35dff3af14c..1613b1cb868 100644 --- a/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts +++ b/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts @@ -36,7 +36,7 @@ verify.navigationTree({ "childItems": [ { "text": "LocalEnumMemberInConstructor", - "kind": "const" + "kind": "enum member" } ] }, @@ -64,7 +64,7 @@ verify.navigationTree({ "childItems": [ { "text": "LocalEnumMemberInMethod", - "kind": "const" + "kind": "enum member" } ] }, @@ -144,7 +144,7 @@ verify.navigationBar([ "childItems": [ { "text": "LocalEnumMemberInConstructor", - "kind": "const" + "kind": "enum member" } ], "indent": 3 @@ -184,7 +184,7 @@ verify.navigationBar([ "childItems": [ { "text": "LocalEnumMemberInMethod", - "kind": "const" + "kind": "enum member" } ], "indent": 3 diff --git a/tests/cases/fourslash/navigationBarItemsItems.ts b/tests/cases/fourslash/navigationBarItemsItems.ts index 69422dd0cc2..4597ac6474b 100644 --- a/tests/cases/fourslash/navigationBarItemsItems.ts +++ b/tests/cases/fourslash/navigationBarItemsItems.ts @@ -130,15 +130,15 @@ verify.navigationTree({ "childItems": [ { "text": "value1", - "kind": "const" + "kind": "enum member" }, { "text": "value2", - "kind": "const" + "kind": "enum member" }, { "text": "value3", - "kind": "const" + "kind": "enum member" } ] } @@ -263,15 +263,15 @@ verify.navigationBar([ "childItems": [ { "text": "value1", - "kind": "const" + "kind": "enum member" }, { "text": "value2", - "kind": "const" + "kind": "enum member" }, { "text": "value3", - "kind": "const" + "kind": "enum member" } ], "indent": 2 diff --git a/tests/cases/fourslash/server/navbar01.ts b/tests/cases/fourslash/server/navbar01.ts index 4a4f59bcf78..edbfca53afb 100644 --- a/tests/cases/fourslash/server/navbar01.ts +++ b/tests/cases/fourslash/server/navbar01.ts @@ -129,15 +129,15 @@ verify.navigationTree({ "childItems": [ { "text": "value1", - "kind": "const" + "kind": "enum member" }, { "text": "value2", - "kind": "const" + "kind": "enum member" }, { "text": "value3", - "kind": "const" + "kind": "enum member" } ] } @@ -262,15 +262,15 @@ verify.navigationBar([ "childItems": [ { "text": "value1", - "kind": "const" + "kind": "enum member" }, { "text": "value2", - "kind": "const" + "kind": "enum member" }, { "text": "value3", - "kind": "const" + "kind": "enum member" } ], "indent": 2 From de5091081a4768ff7684170d2ad8137cc02efaa0 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 14 Feb 2017 06:53:44 -0800 Subject: [PATCH 006/167] Fix failing tests --- src/compiler/utilities.ts | 2 +- tests/baselines/reference/extendsUntypedModule.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 6a338a0f9d2..f4c505b9450 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -426,7 +426,7 @@ namespace ts { /** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */ export function isUntypedOrShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean { - return !moduleSymbol.valueDeclaration || isShorthandAmbientModule(moduleSymbol.valueDeclaration); + return !moduleSymbol.declarations || isShorthandAmbientModule(moduleSymbol.valueDeclaration); } function isShorthandAmbientModule(node: Node): boolean { diff --git a/tests/baselines/reference/extendsUntypedModule.js b/tests/baselines/reference/extendsUntypedModule.js index ad35e4abaac..f86ded7e6cb 100644 --- a/tests/baselines/reference/extendsUntypedModule.js +++ b/tests/baselines/reference/extendsUntypedModule.js @@ -22,6 +22,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +exports.__esModule = true; var foo_1 = require("foo"); var A = (function (_super) { __extends(A, _super); From a742f6271c524790c7cebb8938e7034966bbfa53 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 14 Feb 2017 08:46:58 -0800 Subject: [PATCH 007/167] Handle additional cases --- src/services/symbolDisplay.ts | 12 ++++++---- .../quickInfoDisplayPartsEnum1.baseline | 24 +++++++++---------- .../quickInfoDisplayPartsEnum2.baseline | 24 +++++++++---------- .../quickInfoDisplayPartsEnum3.baseline | 24 +++++++++---------- .../fourslash/quickInfoDisplayPartsEnum1.ts | 4 +++- 5 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 58c83de8509..6a6cd5cd8b3 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -2,7 +2,7 @@ namespace ts.SymbolDisplay { // TODO(drosen): use contextual SemanticMeaning. export function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): string { - const flags = symbol.getFlags(); + const { flags } = symbol; if (flags & SymbolFlags.Class) return getDeclarationOfKind(symbol, SyntaxKind.ClassExpression) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; @@ -11,10 +11,10 @@ namespace ts.SymbolDisplay { if (flags & SymbolFlags.Interface) return ScriptElementKind.interfaceElement; if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement; - const result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location); + const result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); if (result === ScriptElementKind.unknown) { if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement; - if (flags & SymbolFlags.EnumMember) return ScriptElementKind.variableElement; + if (flags & SymbolFlags.EnumMember) return ScriptElementKind.enumMemberElement; if (flags & SymbolFlags.Alias) return ScriptElementKind.alias; if (flags & SymbolFlags.Module) return ScriptElementKind.moduleElement; } @@ -22,7 +22,7 @@ namespace ts.SymbolDisplay { return result; } - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker: TypeChecker, symbol: Symbol, flags: SymbolFlags, location: Node) { + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker: TypeChecker, symbol: Symbol, location: Node) { if (typeChecker.isUndefinedSymbol(symbol)) { return ScriptElementKind.variableElement; } @@ -32,6 +32,7 @@ namespace ts.SymbolDisplay { if (location.kind === SyntaxKind.ThisKeyword && isExpression(location)) { return ScriptElementKind.parameterElement; } + const { flags } = symbol; if (flags & SymbolFlags.Variable) { if (isFirstDeclarationOfSymbolParameter(symbol)) { return ScriptElementKind.parameterElement; @@ -90,7 +91,7 @@ namespace ts.SymbolDisplay { const displayParts: SymbolDisplayPart[] = []; let documentation: SymbolDisplayPart[]; const symbolFlags = symbol.flags; - let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); + let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); let hasAddedSymbolInfo: boolean; const isThisExpression = location.kind === SyntaxKind.ThisKeyword && isExpression(location); let type: Type; @@ -311,6 +312,7 @@ namespace ts.SymbolDisplay { } } if (symbolFlags & SymbolFlags.EnumMember) { + symbolKind = ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); const declaration = symbol.declarations[0]; if (declaration.kind === SyntaxKind.EnumMember) { diff --git a/tests/baselines/reference/quickInfoDisplayPartsEnum1.baseline b/tests/baselines/reference/quickInfoDisplayPartsEnum1.baseline index 142840b9f01..6dc27a4a5b3 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsEnum1.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsEnum1.baseline @@ -34,7 +34,7 @@ "position": 13 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 13, @@ -95,7 +95,7 @@ "position": 21 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 21, @@ -156,7 +156,7 @@ "position": 34 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 34, @@ -357,7 +357,7 @@ "position": 71 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 71, @@ -488,7 +488,7 @@ "position": 89 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 89, @@ -619,7 +619,7 @@ "position": 107 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 107, @@ -717,7 +717,7 @@ "position": 135 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 135, @@ -778,7 +778,7 @@ "position": 143 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 143, @@ -839,7 +839,7 @@ "position": 156 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 156, @@ -1056,7 +1056,7 @@ "position": 205 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 205, @@ -1195,7 +1195,7 @@ "position": 229 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 229, @@ -1334,7 +1334,7 @@ "position": 253 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 253, diff --git a/tests/baselines/reference/quickInfoDisplayPartsEnum2.baseline b/tests/baselines/reference/quickInfoDisplayPartsEnum2.baseline index efdff818b0f..43d0683faef 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsEnum2.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsEnum2.baseline @@ -34,7 +34,7 @@ "position": 13 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 13, @@ -99,7 +99,7 @@ "position": 23 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 23, @@ -164,7 +164,7 @@ "position": 38 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 38, @@ -369,7 +369,7 @@ "position": 77 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 77, @@ -504,7 +504,7 @@ "position": 95 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 95, @@ -639,7 +639,7 @@ "position": 113 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 113, @@ -741,7 +741,7 @@ "position": 141 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 141, @@ -806,7 +806,7 @@ "position": 151 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 151, @@ -871,7 +871,7 @@ "position": 166 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 166, @@ -1092,7 +1092,7 @@ "position": 217 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 217, @@ -1235,7 +1235,7 @@ "position": 241 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 241, @@ -1378,7 +1378,7 @@ "position": 265 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 265, diff --git a/tests/baselines/reference/quickInfoDisplayPartsEnum3.baseline b/tests/baselines/reference/quickInfoDisplayPartsEnum3.baseline index 919816394e2..b9f6483f63a 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsEnum3.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsEnum3.baseline @@ -34,7 +34,7 @@ "position": 13 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 13, @@ -99,7 +99,7 @@ "position": 23 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 23, @@ -164,7 +164,7 @@ "position": 38 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 38, @@ -369,7 +369,7 @@ "position": 77 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 77, @@ -504,7 +504,7 @@ "position": 98 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 98, @@ -639,7 +639,7 @@ "position": 119 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 119, @@ -741,7 +741,7 @@ "position": 150 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 150, @@ -806,7 +806,7 @@ "position": 160 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 160, @@ -871,7 +871,7 @@ "position": 175 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 175, @@ -1092,7 +1092,7 @@ "position": 226 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 226, @@ -1235,7 +1235,7 @@ "position": 253 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 253, @@ -1378,7 +1378,7 @@ "position": 280 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 280, diff --git a/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts b/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts index 628fe9c757e..0bc3c1ab89b 100644 --- a/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts +++ b/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts @@ -19,4 +19,6 @@ /////*25*/eInstance1 = /*26*/constE./*27*/e2; /////*28*/eInstance1 = /*29*/constE./*30*/e3; -verify.baselineQuickInfo(); \ No newline at end of file +//goTo.marker("2"); +//verify.verifyQuickInfoDisplayParts("enum member", "", { start: 0, length: 2 }, /*displayParts*/[], /*documentation*/[]); +verify.baselineQuickInfo(); From f6a3a3fc3dc5aac5d5b1bbec8a64656be6cbda85 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 14 Feb 2017 12:04:39 -0800 Subject: [PATCH 008/167] Use '__this__' property in contextual type to indicate type of 'this' --- src/compiler/checker.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2b059e29d09..1f59d28cc7c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11189,6 +11189,19 @@ namespace ts { return getTypeOfSymbol(thisParameter); } } + if (isObjectLiteralMethod(func)) { + // For methods in an object literal, look for a '__this__' property in the contextual + // type for the object literal. If one exists, remove 'undefined' from the type of that + // property and report it as the contextual type for 'this' in the method. + const objectLiteral = func.parent; + const type = getApparentTypeOfContextualType(objectLiteral); + if (type) { + const propertyType = getTypeOfPropertyOfContextualType(type, "___this__"); + if (propertyType) { + return getNonNullableType(propertyType); + } + } + } } return undefined; } From 896e576374f3bbbb2e1781773664591608425af2 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 16 Feb 2017 13:17:42 -0800 Subject: [PATCH 009/167] fix typo --- src/compiler/binder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 446fadcc3b4..493101f1688 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1314,7 +1314,7 @@ namespace ts { function bindJSDocTypedefTag(node: JSDocTypedefTag) { forEachChild(node, n => { - // if the node has a fullName "A.B.C", that means symbol "C" was already bond + // if the node has a fullName "A.B.C", that means symbol "C" was already bound // when we visit "fullName"; so when we visit the name "C" as the next child of // the jsDocTypedefTag, we should skip binding it. if (n === node.name && node.fullName.kind !== SyntaxKind.Identifier) { From ea01ad4cbdd84f3ccdf79e3843722c9d544211b5 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 16 Feb 2017 14:03:41 -0800 Subject: [PATCH 010/167] Check for conflict marker when trying to parse JSX child --- src/compiler/parser.ts | 3 +++ src/compiler/scanner.ts | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ebd4208832c..2aaf1cb4124 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3862,6 +3862,9 @@ namespace ts { parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTagName)); break; } + else if (token() === SyntaxKind.ConflictMarkerTrivia) { + break; + } result.push(parseJsxChild()); } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 52c75a37005..54cd191b43d 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1716,9 +1716,18 @@ namespace ts { while (pos < end) { pos++; char = text.charCodeAt(pos); - if ((char === CharacterCodes.openBrace) || (char === CharacterCodes.lessThan)) { + if (char === CharacterCodes.openBrace) { break; } + if (char === CharacterCodes.lessThan) { + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + return token = SyntaxKind.ConflictMarkerTrivia; + } + else { + break; + } + } } return token = SyntaxKind.JsxText; } From 8f79f9529f73cb34c75a39649650093ef34230e1 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 16 Feb 2017 14:03:59 -0800 Subject: [PATCH 011/167] Add tests and baselines --- .../reference/conflictMarkerTrivia3.errors.txt | 15 +++++++++++++++ .../baselines/reference/conflictMarkerTrivia3.js | 6 ++++++ .../reference/conflictMarkerTrivia4.errors.txt | 14 ++++++++++++++ .../baselines/reference/conflictMarkerTrivia4.js | 6 ++++++ tests/cases/compiler/conflictMarkerTrivia3.tsx | 2 ++ tests/cases/compiler/conflictMarkerTrivia4.ts | 2 ++ 6 files changed, 45 insertions(+) create mode 100644 tests/baselines/reference/conflictMarkerTrivia3.errors.txt create mode 100644 tests/baselines/reference/conflictMarkerTrivia3.js create mode 100644 tests/baselines/reference/conflictMarkerTrivia4.errors.txt create mode 100644 tests/baselines/reference/conflictMarkerTrivia4.js create mode 100644 tests/cases/compiler/conflictMarkerTrivia3.tsx create mode 100644 tests/cases/compiler/conflictMarkerTrivia4.ts diff --git a/tests/baselines/reference/conflictMarkerTrivia3.errors.txt b/tests/baselines/reference/conflictMarkerTrivia3.errors.txt new file mode 100644 index 00000000000..124201ce0ba --- /dev/null +++ b/tests/baselines/reference/conflictMarkerTrivia3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/conflictMarkerTrivia3.tsx(1,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. +tests/cases/compiler/conflictMarkerTrivia3.tsx(1,16): error TS1005: ' + ~~~~~ +!!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. + + <<<<<<< HEAD + ~~~~~~~~~~~~ +!!! error TS1005: ' +<<<<<<< HEAD + +//// [conflictMarkerTrivia3.js] +var x =
; diff --git a/tests/baselines/reference/conflictMarkerTrivia4.errors.txt b/tests/baselines/reference/conflictMarkerTrivia4.errors.txt new file mode 100644 index 00000000000..476dbbce6ce --- /dev/null +++ b/tests/baselines/reference/conflictMarkerTrivia4.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/conflictMarkerTrivia4.ts(1,12): error TS2304: Cannot find name 'div'. +tests/cases/compiler/conflictMarkerTrivia4.ts(2,1): error TS1185: Merge conflict marker encountered. +tests/cases/compiler/conflictMarkerTrivia4.ts(2,13): error TS1109: Expression expected. + + +==== tests/cases/compiler/conflictMarkerTrivia4.ts (3 errors) ==== + const x =
+ ~~~ +!!! error TS2304: Cannot find name 'div'. + <<<<<<< HEAD + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + +!!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/conflictMarkerTrivia4.js b/tests/baselines/reference/conflictMarkerTrivia4.js new file mode 100644 index 00000000000..945e82b2f2d --- /dev/null +++ b/tests/baselines/reference/conflictMarkerTrivia4.js @@ -0,0 +1,6 @@ +//// [conflictMarkerTrivia4.ts] +const x =
+<<<<<<< HEAD + +//// [conflictMarkerTrivia4.js] +var x = ; diff --git a/tests/cases/compiler/conflictMarkerTrivia3.tsx b/tests/cases/compiler/conflictMarkerTrivia3.tsx new file mode 100644 index 00000000000..21f83715ad0 --- /dev/null +++ b/tests/cases/compiler/conflictMarkerTrivia3.tsx @@ -0,0 +1,2 @@ +const x =
+<<<<<<< HEAD \ No newline at end of file diff --git a/tests/cases/compiler/conflictMarkerTrivia4.ts b/tests/cases/compiler/conflictMarkerTrivia4.ts new file mode 100644 index 00000000000..21f83715ad0 --- /dev/null +++ b/tests/cases/compiler/conflictMarkerTrivia4.ts @@ -0,0 +1,2 @@ +const x =
+<<<<<<< HEAD \ No newline at end of file From f6e9dad838b95ef6895d00333d7e1de9ab9de8cc Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 16 Feb 2017 14:04:43 -0800 Subject: [PATCH 012/167] Check `fullName` has value for typedefTag --- src/compiler/binder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 493101f1688..723148ba93e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1317,7 +1317,7 @@ namespace ts { // if the node has a fullName "A.B.C", that means symbol "C" was already bound // when we visit "fullName"; so when we visit the name "C" as the next child of // the jsDocTypedefTag, we should skip binding it. - if (n === node.name && node.fullName.kind !== SyntaxKind.Identifier) { + if (node.fullName && n === node.name && node.fullName.kind !== SyntaxKind.Identifier) { return; } bind(n); From e66c824f31e01340af34e47417a224f8b9b721dd Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 16 Feb 2017 14:07:27 -0800 Subject: [PATCH 013/167] Remove unnecessary else clause --- src/compiler/scanner.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 54cd191b43d..82d75d2fa7c 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1724,9 +1724,7 @@ namespace ts { pos = scanConflictMarkerTrivia(text, pos, error); return token = SyntaxKind.ConflictMarkerTrivia; } - else { - break; - } + break; } } return token = SyntaxKind.JsxText; From 8cd6c5d8eb27dc12f3fbc17236271440214d2690 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 16 Feb 2017 17:03:39 -0800 Subject: [PATCH 014/167] Introduce ThisType marker interface --- src/compiler/checker.ts | 53 +++++++++++++++++++++++++++++++---------- src/lib/es5.d.ts | 5 ++++ 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1f59d28cc7c..898b7b4d539 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -197,6 +197,7 @@ namespace ts { let globalNumberType: ObjectType; let globalBooleanType: ObjectType; let globalRegExpType: ObjectType; + let globalThisType: GenericType; let anyArrayType: Type; let autoArrayType: Type; let anyReadonlyArrayType: Type; @@ -5802,6 +5803,11 @@ namespace ts { return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } + function getGlobalTypeOrUndefined(name: string, arity = 0): ObjectType { + const symbol = getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined); + return symbol && getTypeOfGlobalSymbol(symbol, arity); + } + /** * Returns a type that is inside a namespace at the global scope, e.g. * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type @@ -11180,6 +11186,22 @@ namespace ts { } } + function getContainingObjectLiteral(func: FunctionLikeDeclaration) { + return func.kind === SyntaxKind.MethodDeclaration && func.parent.kind === SyntaxKind.ObjectLiteralExpression ? func.parent : + func.kind === SyntaxKind.FunctionExpression && func.parent.kind === SyntaxKind.PropertyAssignment ? func.parent.parent : + undefined; + } + + function getThisTypeArgument(type: Type): Type { + return getObjectFlags(type) & ObjectFlags.Reference && (type).target === globalThisType ? (type).typeArguments[0] : undefined; + } + + function getThisTypeFromContextualType(type: Type): Type { + return applyToContextualType(type, t => { + return t.flags & TypeFlags.Intersection ? forEach((t).types, getThisTypeArgument) : getThisTypeArgument(t); + }); + } + function getContextualThisParameterType(func: FunctionLikeDeclaration): Type { if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) { const contextualSignature = getContextualSignature(func); @@ -11189,17 +11211,24 @@ namespace ts { return getTypeOfSymbol(thisParameter); } } - if (isObjectLiteralMethod(func)) { - // For methods in an object literal, look for a '__this__' property in the contextual - // type for the object literal. If one exists, remove 'undefined' from the type of that - // property and report it as the contextual type for 'this' in the method. - const objectLiteral = func.parent; - const type = getApparentTypeOfContextualType(objectLiteral); - if (type) { - const propertyType = getTypeOfPropertyOfContextualType(type, "___this__"); - if (propertyType) { - return getNonNullableType(propertyType); + const containingLiteral = getContainingObjectLiteral(func); + if (containingLiteral) { + // We have an object literal method. Check if the containing object literal has a contextual type + // and if that contextual type is or includes a ThisType. If so, T is the contextual type for + // 'this'. We continue looking in any directly enclosing object literals. + let objectLiteral = containingLiteral; + while (true) { + const type = getApparentTypeOfContextualType(objectLiteral); + if (type) { + const thisType = getThisTypeFromContextualType(type); + if (thisType) { + return thisType; + } } + if (objectLiteral.parent.kind !== SyntaxKind.PropertyAssignment) { + break; + } + objectLiteral = objectLiteral.parent.parent; } } } @@ -21175,9 +21204,9 @@ namespace ts { anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); - const symbol = getGlobalSymbol("ReadonlyArray", SymbolFlags.Type, /*diagnostic*/ undefined); - globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); + globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", /*arity*/ 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; + globalThisType = getGlobalTypeOrUndefined("ThisType", /*arity*/ 1); } function checkExternalEmitHelpers(location: Node, helpers: ExternalEmitHelpers) { diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 038d0344fda..6ff9b8f533a 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1384,6 +1384,11 @@ type Record = { [P in K]: T; } +/** + * Marker for contextual 'this' type + */ +interface ThisType { } + /** * Represents a raw buffer of binary data, which is used to store data for the * different typed arrays. ArrayBuffers cannot be read from or written to directly, From 2ca6164fea89ca344b04ee775a472564ae836511 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 16 Feb 2017 17:04:30 -0800 Subject: [PATCH 015/167] Default contextual 'this' type is containing object literal --- src/compiler/checker.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 898b7b4d539..3949a65eea8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11230,6 +11230,9 @@ namespace ts { } objectLiteral = objectLiteral.parent.parent; } + // There was no contextual ThisType for the containing object literal, so the contextual type + // for 'this' is the type of the object literal itself. + return checkExpressionCached(containingLiteral); } } return undefined; From 7d82e15ee50c3a8235875d9e2ffa99c9e9bc7ba5 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Feb 2017 17:10:33 -0800 Subject: [PATCH 016/167] Add tests --- .../codeFixClassExtendAbstractGetter.ts | 11 ---------- .../codeFixClassExtendAbstractGetterSetter.ts | 22 +++++++++++++++---- .../codeFixClassExtendAbstractProperty.ts | 4 ++++ .../codeFixClassExtendAbstractSetter.ts | 11 ---------- 4 files changed, 22 insertions(+), 26 deletions(-) delete mode 100644 tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts delete mode 100644 tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts deleted file mode 100644 index 8d79cce710e..00000000000 --- a/tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -//// abstract class A { -//// abstract get b(): number; -//// } -//// -//// class C extends A {[| |]} - -verify.rangeAfterCodeFix(` - b: number; -`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts index fc0ac400623..4bddfb799f2 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts @@ -2,9 +2,17 @@ //// abstract class A { //// private _a: string; -//// -//// abstract get a(): string; -//// abstract set a(newName: string); +//// +//// abstract get a(): number | string; +//// abstract get b(): this; +//// abstract get c(): A; +//// +//// abstract set d(arg: number | string); +//// abstract set e(arg: this); +//// abstract set f(arg: A); +//// +//// abstract get g(): string; +//// abstract set g(newName: string); //// } //// //// // Don't need to add anything in this case. @@ -13,5 +21,11 @@ //// class C extends A {[| |]} verify.rangeAfterCodeFix(` - a: string; + a: string | number; + b: this; + c: A; + d: string | number; + e: this; + f: A; + g: string; `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts index 3160a3b9a08..b7300acf5ae 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts @@ -2,6 +2,8 @@ //// abstract class A { //// abstract x: number; +//// abstract y: this; +//// abstract z: A; //// abstract foo(): number; //// } //// @@ -10,6 +12,8 @@ verify.rangeAfterCodeFix(` x: number; + y: this; + z: A; foo(): number { throw new Error('Method not implemented.'); } diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts deleted file mode 100644 index e8cb55fa660..00000000000 --- a/tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -//// abstract class A { -//// abstract set c(arg: number | string); -//// } -//// -//// class C extends A {[| |]} - -verify.rangeAfterCodeFix(` - c: string | number; -`); \ No newline at end of file From 33fc26cb9c4ea8e0ace668283abc81ac9a43c28b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Feb 2017 17:11:01 -0800 Subject: [PATCH 017/167] Detect this type for codefix --- src/services/codefixes/helpers.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 3eab994f84c..45479e49474 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -23,8 +23,6 @@ namespace ts.codefix { * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ function getInsertionForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker, newlineChar: string): string { - // const name = symbol.getName(); - const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); const declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return ""; @@ -34,12 +32,22 @@ namespace ts.codefix { const name = declaration.name ? declaration.name.getText() : undefined; const visibility = getVisibilityPrefixWithSpace(getModifierFlags(declaration)); + const typeAtNewDeclaration = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + switch (declaration.kind) { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: - const typeString = checker.typeToString(type, enclosingDeclaration, TypeFormatFlags.None); + let typeString: string | undefined = undefined; + const typeAtOldDeclaration = checker.getTypeAtLocation(declaration); + if ((typeAtOldDeclaration as TypeParameter).isThisType) { + typeString = "this"; + } + else { + typeString = checker.typeToString(typeAtNewDeclaration, enclosingDeclaration, TypeFormatFlags.None); + } + return `${visibility}${name}: ${typeString};${newlineChar}`; case SyntaxKind.MethodSignature: @@ -51,7 +59,7 @@ namespace ts.codefix { // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - const signatures = checker.getSignaturesOfType(type, SignatureKind.Call); + const signatures = checker.getSignaturesOfType(typeAtNewDeclaration, SignatureKind.Call); if (!(signatures && signatures.length > 0)) { return ""; } From e512376b0c5ae25d0e66b4c92bc6618cbd262c95 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 16 Feb 2017 17:42:22 -0800 Subject: [PATCH 018/167] Update tests --- tests/cases/compiler/noImplicitThisObjectLiterals.ts | 10 ---------- .../typePredicates/declarationEmitThisPredicates02.ts | 2 +- .../declarationEmitThisPredicatesWithPrivateName02.ts | 2 +- .../expressions/thisKeyword/thisInObjectLiterals.ts | 3 ++- .../conformance/types/thisType/thisTypeInFunctions2.ts | 7 +++---- 5 files changed, 7 insertions(+), 17 deletions(-) delete mode 100644 tests/cases/compiler/noImplicitThisObjectLiterals.ts diff --git a/tests/cases/compiler/noImplicitThisObjectLiterals.ts b/tests/cases/compiler/noImplicitThisObjectLiterals.ts deleted file mode 100644 index abd5d9dcfba..00000000000 --- a/tests/cases/compiler/noImplicitThisObjectLiterals.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @noImplicitThis: true -let o = { - d: this, // error, this: any - m() { - return this.d.length; // error, this: any - }, - f: function() { - return this.d.length; // error, this: any - } -} diff --git a/tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts b/tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts index 02f2a798831..c17b26f423c 100644 --- a/tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts +++ b/tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts @@ -9,7 +9,7 @@ export interface Foo { export const obj = { m(): this is Foo { - let dis = this as Foo; + let dis = this as {} as Foo; return dis.a != null && dis.b != null && dis.c != null; } } \ No newline at end of file diff --git a/tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts b/tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts index c238bb16ec8..94e657db9f3 100644 --- a/tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts +++ b/tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts @@ -9,7 +9,7 @@ interface Foo { export const obj = { m(): this is Foo { - let dis = this as Foo; + let dis = this as {} as Foo; return dis.a != null && dis.b != null && dis.c != null; } } \ No newline at end of file diff --git a/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts b/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts index ddfbb790980..6219586b6e5 100644 --- a/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts +++ b/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts @@ -2,9 +2,10 @@ class MyClass { t: number; fn() { + type ContainingThis = this; //type of 'this' in an object literal is the containing scope's this var t = { x: this, y: this.t }; - var t: { x: MyClass; y: number }; + var t: { x: ContainingThis; y: number }; } } diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts index a574c7a07e9..0d1581633c3 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts @@ -32,15 +32,14 @@ extend1({ }); extend2({ init() { - this // this: any because the contextual signature of init doesn't specify this' type + this // this: containing object literal type this.mine - this.willDestroy + //this.willDestroy }, mine: 13, foo() { - this // this: any because of the string indexer + this // this: containing object literal type this.mine - this.willDestroy } }); From d7e153d25228c9c8527dd9d38b464c53729b959d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 16 Feb 2017 17:47:58 -0800 Subject: [PATCH 019/167] Accept new baselines --- tests/baselines/reference/castTest.symbols | 6 ++ tests/baselines/reference/castTest.types | 16 +-- .../commentsOnObjectLiteral2.errors.txt | 5 +- ...declarationEmitThisPredicates02.errors.txt | 2 +- .../declarationEmitThisPredicates02.js | 2 +- ...ThisPredicatesWithPrivateName02.errors.txt | 2 +- ...tionEmitThisPredicatesWithPrivateName02.js | 2 +- .../reference/fatarrowfunctions.symbols | 5 + .../reference/fatarrowfunctions.types | 12 +-- .../fatarrowfunctionsInFunctions.symbols | 5 + .../fatarrowfunctionsInFunctions.types | 16 +-- .../reference/fixSignatureCaching.errors.txt | 98 ++++++++++++++++++- .../looseThisTypeInFunctions.errors.txt | 5 +- .../baselines/reference/objectSpread.symbols | 3 + tests/baselines/reference/objectSpread.types | 12 +-- .../baselines/reference/selfInLambdas.symbols | 7 ++ tests/baselines/reference/selfInLambdas.types | 16 +-- .../baselines/reference/thisBinding2.symbols | 3 + tests/baselines/reference/thisBinding2.types | 8 +- .../reference/thisInObjectLiterals.errors.txt | 9 +- .../reference/thisInObjectLiterals.js | 3 +- .../thisInPropertyBoundDeclarations.symbols | 2 + .../thisInPropertyBoundDeclarations.types | 12 +-- .../reference/thisTypeInFunctions2.js | 14 ++- .../reference/thisTypeInFunctions2.symbols | 29 ++++-- .../reference/thisTypeInFunctions2.types | 49 ++++------ .../thisTypeInObjectLiterals.symbols | 24 +++++ .../reference/thisTypeInObjectLiterals.types | 78 +++++++-------- .../throwInEnclosingStatements.symbols | 1 + .../throwInEnclosingStatements.types | 2 +- .../reference/underscoreTest1.symbols | 6 ++ .../baselines/reference/underscoreTest1.types | 12 +-- 32 files changed, 317 insertions(+), 149 deletions(-) diff --git a/tests/baselines/reference/castTest.symbols b/tests/baselines/reference/castTest.symbols index 944cc8238e6..706f75a1028 100644 --- a/tests/baselines/reference/castTest.symbols +++ b/tests/baselines/reference/castTest.symbols @@ -71,7 +71,13 @@ var p_cast = ({ return new Point(this.x + dx, this.y + dy); >Point : Symbol(Point, Decl(castTest.ts, 11, 37)) +>this.x : Symbol(x, Decl(castTest.ts, 22, 23)) +>this : Symbol(__object, Decl(castTest.ts, 22, 22)) +>x : Symbol(x, Decl(castTest.ts, 22, 23)) >dx : Symbol(dx, Decl(castTest.ts, 25, 18)) +>this.y : Symbol(y, Decl(castTest.ts, 23, 9)) +>this : Symbol(__object, Decl(castTest.ts, 22, 22)) +>y : Symbol(y, Decl(castTest.ts, 23, 9)) >dy : Symbol(dy, Decl(castTest.ts, 25, 21)) }, diff --git a/tests/baselines/reference/castTest.types b/tests/baselines/reference/castTest.types index 666b2ccf78e..acdc58d0b25 100644 --- a/tests/baselines/reference/castTest.types +++ b/tests/baselines/reference/castTest.types @@ -91,15 +91,15 @@ var p_cast = ({ return new Point(this.x + dx, this.y + dy); >new Point(this.x + dx, this.y + dy) : Point >Point : typeof Point ->this.x + dx : any ->this.x : any ->this : any ->x : any +>this.x + dx : number +>this.x : number +>this : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; } +>x : number >dx : number ->this.y + dy : any ->this.y : any ->this : any ->y : any +>this.y + dy : number +>this.y : number +>this : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; } +>y : number >dy : number }, diff --git a/tests/baselines/reference/commentsOnObjectLiteral2.errors.txt b/tests/baselines/reference/commentsOnObjectLiteral2.errors.txt index 2a2394ced48..3748d0387b6 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral2.errors.txt +++ b/tests/baselines/reference/commentsOnObjectLiteral2.errors.txt @@ -1,7 +1,8 @@ tests/cases/compiler/commentsOnObjectLiteral2.ts(1,14): error TS2304: Cannot find name 'makeClass'. +tests/cases/compiler/commentsOnObjectLiteral2.ts(9,17): error TS2339: Property 'name' does not exist on type '{ initialize: (name: any) => void; }'. -==== tests/cases/compiler/commentsOnObjectLiteral2.ts (1 errors) ==== +==== tests/cases/compiler/commentsOnObjectLiteral2.ts (2 errors) ==== var Person = makeClass( ~~~~~~~~~ !!! error TS2304: Cannot find name 'makeClass'. @@ -13,6 +14,8 @@ tests/cases/compiler/commentsOnObjectLiteral2.ts(1,14): error TS2304: Cannot fin */ initialize: function(name) { this.name = name; + ~~~~ +!!! error TS2339: Property 'name' does not exist on type '{ initialize: (name: any) => void; }'. } /* trailing comment 1*/, } ); \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt index 4d95cf01136..e4f95d98803 100644 --- a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt @@ -13,7 +13,7 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredic m(): this is Foo { ~~~~ !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. - let dis = this as Foo; + let dis = this as {} as Foo; return dis.a != null && dis.b != null && dis.c != null; } } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitThisPredicates02.js b/tests/baselines/reference/declarationEmitThisPredicates02.js index 0e7c99df1f3..46deae372ca 100644 --- a/tests/baselines/reference/declarationEmitThisPredicates02.js +++ b/tests/baselines/reference/declarationEmitThisPredicates02.js @@ -8,7 +8,7 @@ export interface Foo { export const obj = { m(): this is Foo { - let dis = this as Foo; + let dis = this as {} as Foo; return dis.a != null && dis.b != null && dis.c != null; } } diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt index 86c0f478133..bd2f4700fa2 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt @@ -16,7 +16,7 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredic m(): this is Foo { ~~~~ !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. - let dis = this as Foo; + let dis = this as {} as Foo; return dis.a != null && dis.b != null && dis.c != null; } } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js index 7ec7ba5dec8..fe1a95db5e3 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js @@ -8,7 +8,7 @@ interface Foo { export const obj = { m(): this is Foo { - let dis = this as Foo; + let dis = this as {} as Foo; return dis.a != null && dis.b != null && dis.c != null; } } diff --git a/tests/baselines/reference/fatarrowfunctions.symbols b/tests/baselines/reference/fatarrowfunctions.symbols index 6ed865b0914..1e5fb4f3178 100644 --- a/tests/baselines/reference/fatarrowfunctions.symbols +++ b/tests/baselines/reference/fatarrowfunctions.symbols @@ -163,6 +163,11 @@ var messenger = { setTimeout(() => { this.message.toString(); }, 3000); >setTimeout : Symbol(setTimeout, Decl(fatarrowfunctions.ts, 34, 1)) +>this.message.toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) +>this.message : Symbol(message, Decl(fatarrowfunctions.ts, 38, 17)) +>this : Symbol(__object, Decl(fatarrowfunctions.ts, 38, 15)) +>message : Symbol(message, Decl(fatarrowfunctions.ts, 38, 17)) +>toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) } }; diff --git a/tests/baselines/reference/fatarrowfunctions.types b/tests/baselines/reference/fatarrowfunctions.types index 304c341c916..1114ae365cb 100644 --- a/tests/baselines/reference/fatarrowfunctions.types +++ b/tests/baselines/reference/fatarrowfunctions.types @@ -234,12 +234,12 @@ var messenger = { >setTimeout(() => { this.message.toString(); }, 3000) : number >setTimeout : (expression: any, msec?: number, language?: any) => number >() => { this.message.toString(); } : () => void ->this.message.toString() : any ->this.message.toString : any ->this.message : any ->this : any ->message : any ->toString : any +>this.message.toString() : string +>this.message.toString : () => string +>this.message : string +>this : { message: string; start: () => void; } +>message : string +>toString : () => string >3000 : 3000 } }; diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols b/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols index 0a86affc215..f1123f4aa96 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols +++ b/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols @@ -16,12 +16,17 @@ var messenger = { var _self = this; >_self : Symbol(_self, Decl(fatarrowfunctionsInFunctions.ts, 5, 11)) +>this : Symbol(__object, Decl(fatarrowfunctionsInFunctions.ts, 2, 15)) setTimeout(function() { >setTimeout : Symbol(setTimeout, Decl(fatarrowfunctionsInFunctions.ts, 0, 0)) _self.message.toString(); +>_self.message.toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) +>_self.message : Symbol(message, Decl(fatarrowfunctionsInFunctions.ts, 2, 17)) >_self : Symbol(_self, Decl(fatarrowfunctionsInFunctions.ts, 5, 11)) +>message : Symbol(message, Decl(fatarrowfunctionsInFunctions.ts, 2, 17)) +>toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) }, 3000); } diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctions.types b/tests/baselines/reference/fatarrowfunctionsInFunctions.types index 8b9bd7ccd7a..88807f2a37b 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctions.types +++ b/tests/baselines/reference/fatarrowfunctionsInFunctions.types @@ -18,8 +18,8 @@ var messenger = { >function() { var _self = this; setTimeout(function() { _self.message.toString(); }, 3000); } : () => void var _self = this; ->_self : any ->this : any +>_self : { message: string; start: () => void; } +>this : { message: string; start: () => void; } setTimeout(function() { >setTimeout(function() { _self.message.toString(); }, 3000) : number @@ -27,12 +27,12 @@ var messenger = { >function() { _self.message.toString(); } : () => void _self.message.toString(); ->_self.message.toString() : any ->_self.message.toString : any ->_self.message : any ->_self : any ->message : any ->toString : any +>_self.message.toString() : string +>_self.message.toString : () => string +>_self.message : string +>_self : { message: string; start: () => void; } +>message : string +>toString : () => string }, 3000); >3000 : 3000 diff --git a/tests/baselines/reference/fixSignatureCaching.errors.txt b/tests/baselines/reference/fixSignatureCaching.errors.txt index 7a5c43c966e..284a0d13926 100644 --- a/tests/baselines/reference/fixSignatureCaching.errors.txt +++ b/tests/baselines/reference/fixSignatureCaching.errors.txt @@ -41,19 +41,51 @@ tests/cases/conformance/fixSignatureCaching.ts(639,38): error TS2304: Cannot fin tests/cases/conformance/fixSignatureCaching.ts(640,13): error TS2304: Cannot find name 'window'. tests/cases/conformance/fixSignatureCaching.ts(641,13): error TS2304: Cannot find name 'window'. tests/cases/conformance/fixSignatureCaching.ts(704,18): error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(704,45): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(704,58): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(704,67): error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(705,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(734,18): error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(734,45): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(734,58): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(734,67): error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(735,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(783,18): error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(783,45): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(783,58): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(783,67): error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(784,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(804,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(805,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(805,46): error TS2339: Property 'findMatch' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(805,61): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(805,89): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(807,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(827,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(828,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(828,47): error TS2339: Property 'findMatches' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(828,64): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(828,92): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(830,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(844,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(845,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(845,39): error TS2339: Property 'detectOS' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(845,53): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(847,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(869,25): error TS2339: Property 'getVersion' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(869,46): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(890,25): error TS2339: Property 'getVersionStr' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(890,49): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(912,36): error TS2339: Property 'findMatches' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(912,53): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(912,83): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(927,38): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(941,33): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. +tests/cases/conformance/fixSignatureCaching.ts(941,68): error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(951,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. +tests/cases/conformance/fixSignatureCaching.ts(952,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(952,42): error TS2339: Property 'mobileGrade' does not exist on type '{}'. +tests/cases/conformance/fixSignatureCaching.ts(954,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(959,16): error TS2304: Cannot find name 'window'. tests/cases/conformance/fixSignatureCaching.ts(959,42): error TS2304: Cannot find name 'window'. tests/cases/conformance/fixSignatureCaching.ts(960,22): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. @@ -71,7 +103,7 @@ tests/cases/conformance/fixSignatureCaching.ts(979,23): error TS2304: Cannot fin tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot find name 'window'. -==== tests/cases/conformance/fixSignatureCaching.ts (71 errors) ==== +==== tests/cases/conformance/fixSignatureCaching.ts (103 errors) ==== // Repro from #10697 (function (define, undefined) { @@ -862,7 +894,15 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. + ~~~~~~~~~~~~~ +!!! error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. return this._cache.mobile; + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -894,7 +934,15 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. + ~~~~~~~~~~~~~ +!!! error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. return this._cache.phone; + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -945,7 +993,15 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. + ~~~~~~~~~~~~~ +!!! error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. return this._cache.tablet; + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -966,13 +1022,21 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin */ userAgent: function () { if (this._cache.userAgent === undefined) { + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. this._cache.userAgent = impl.findMatch(impl.mobileDetectRules.uas, this.ua); + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. } return this._cache.userAgent; + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -993,13 +1057,21 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin */ userAgents: function () { if (this._cache.userAgents === undefined) { + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. this._cache.userAgents = impl.findMatches(impl.mobileDetectRules.uas, this.ua); + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. } return this._cache.userAgents; + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1014,11 +1086,19 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin */ os: function () { if (this._cache.os === undefined) { + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. this._cache.os = impl.detectOS(this.ua); + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. ~~~~~~~~ !!! error TS2339: Property 'detectOS' does not exist on type '{}'. + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. } return this._cache.os; + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1043,6 +1123,8 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin return impl.getVersion(key, this.ua); ~~~~~~~~~~ !!! error TS2339: Property 'getVersion' does not exist on type '{}'. + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1066,6 +1148,8 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin return impl.getVersionStr(key, this.ua); ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1092,6 +1176,8 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1107,6 +1193,8 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin pattern = new RegExp(pattern, 'i'); } return pattern.test(this.ua); + ~~ +!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1123,6 +1211,8 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin return MobileDetect.isPhoneSized(maxPhoneWidth || this.maxPhoneWidth); ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. + ~~~~~~~~~~~~~ +!!! error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1133,11 +1223,17 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin */ mobileGrade: function () { if (this._cache.grade === undefined) { + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. this._cache.grade = impl.mobileGrade(this); + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. ~~~~~~~~~~~ !!! error TS2339: Property 'mobileGrade' does not exist on type '{}'. } return this._cache.grade; + ~~~~~~ +!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. } }; diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index bf76c9c9641..7e12a714406 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -1,12 +1,13 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. The 'this' types of each signature are incompatible. Type 'void' is not assignable to type 'C'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(25,27): error TS2339: Property 'length' does not exist on type 'number'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,28): error TS2339: Property 'length' does not exist on type 'number'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error TS2339: Property 'length' does not exist on type 'number'. -==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (4 errors) ==== +==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (5 errors) ==== interface I { n: number; explicitThis(this: this, m: number): number; @@ -36,6 +37,8 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error n: 101, explicitThis: function (m: number) { return m + this.n.length; // error, 'length' does not exist on 'number' + ~~~~~~ +!!! error TS2339: Property 'length' does not exist on type 'number'. }, implicitThis(m: number): number { return m; } }; diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 1ec2520e166..3487f757aeb 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -200,6 +200,9 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } } >plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) >c : Symbol(c, Decl(objectSpread.ts, 45, 3)) >plus : Symbol(plus, Decl(objectSpread.ts, 49, 48)) +>this.p : Symbol(C.p, Decl(objectSpread.ts, 44, 9)) +>this : Symbol(__object, Decl(objectSpread.ts, 49, 40)) +>p : Symbol(C.p, Decl(objectSpread.ts, 44, 9)) cplus.plus(); >cplus.plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index 950dab43465..b6ad1d13ae4 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -263,13 +263,13 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } } >cplus : { p: number; plus(): void; } >p : number >plus : () => void ->{ ...c, plus() { return this.p + 1; } } : { plus(): any; p: number; } +>{ ...c, plus() { return this.p + 1; } } : { plus(): number; p: number; } >c : C ->plus : () => any ->this.p + 1 : any ->this.p : any ->this : any ->p : any +>plus : () => number +>this.p + 1 : number +>this.p : number +>this : { plus(): number; p: number; } +>p : number >1 : 1 cplus.plus(); diff --git a/tests/baselines/reference/selfInLambdas.symbols b/tests/baselines/reference/selfInLambdas.symbols index edcc03b6bf6..6f91adefcc1 100644 --- a/tests/baselines/reference/selfInLambdas.symbols +++ b/tests/baselines/reference/selfInLambdas.symbols @@ -37,8 +37,15 @@ var o = { >onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 6, 18)) this.counter++ +>this.counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) +>this : Symbol(__object, Decl(selfInLambdas.ts, 10, 7)) +>counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) + var f = () => this.counter; >f : Symbol(f, Decl(selfInLambdas.ts, 18, 15)) +>this.counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) +>this : Symbol(__object, Decl(selfInLambdas.ts, 10, 7)) +>counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) } diff --git a/tests/baselines/reference/selfInLambdas.types b/tests/baselines/reference/selfInLambdas.types index 614ebc16e68..a26e1e0bf28 100644 --- a/tests/baselines/reference/selfInLambdas.types +++ b/tests/baselines/reference/selfInLambdas.types @@ -43,16 +43,16 @@ var o = { this.counter++ >this.counter++ : number ->this.counter : any ->this : any ->counter : any +>this.counter : number +>this : { counter: number; start: () => void; } +>counter : number var f = () => this.counter; ->f : () => any ->() => this.counter : () => any ->this.counter : any ->this : any ->counter : any +>f : () => number +>() => this.counter : () => number +>this.counter : number +>this : { counter: number; start: () => void; } +>counter : number } diff --git a/tests/baselines/reference/thisBinding2.symbols b/tests/baselines/reference/thisBinding2.symbols index cdef9b60b3e..507b7e48419 100644 --- a/tests/baselines/reference/thisBinding2.symbols +++ b/tests/baselines/reference/thisBinding2.symbols @@ -50,6 +50,9 @@ var messenger = { return setTimeout(() => { var x = this.message; }, 3000); >setTimeout : Symbol(setTimeout, Decl(thisBinding2.ts, 12, 1)) >x : Symbol(x, Decl(thisBinding2.ts, 17, 37)) +>this.message : Symbol(message, Decl(thisBinding2.ts, 14, 17)) +>this : Symbol(__object, Decl(thisBinding2.ts, 14, 15)) +>message : Symbol(message, Decl(thisBinding2.ts, 14, 17)) } }; diff --git a/tests/baselines/reference/thisBinding2.types b/tests/baselines/reference/thisBinding2.types index dbd9f83c741..4889e6d3b33 100644 --- a/tests/baselines/reference/thisBinding2.types +++ b/tests/baselines/reference/thisBinding2.types @@ -67,10 +67,10 @@ var messenger = { >setTimeout(() => { var x = this.message; }, 3000) : number >setTimeout : (expression: any, msec?: number, language?: any) => number >() => { var x = this.message; } : () => void ->x : any ->this.message : any ->this : any ->message : any +>x : string +>this.message : string +>this : { message: string; start: () => number; } +>message : string >3000 : 3000 } }; diff --git a/tests/baselines/reference/thisInObjectLiterals.errors.txt b/tests/baselines/reference/thisInObjectLiterals.errors.txt index e89980dc244..3da8430802d 100644 --- a/tests/baselines/reference/thisInObjectLiterals.errors.txt +++ b/tests/baselines/reference/thisInObjectLiterals.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(7,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type '{ x: this; y: number; }', but here has type '{ x: MyClass; y: number; }'. +tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(15,21): error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'. ==== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts (1 errors) ==== @@ -6,11 +6,10 @@ tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(7,13): e t: number; fn() { + type ContainingThis = this; //type of 'this' in an object literal is the containing scope's this var t = { x: this, y: this.t }; - var t: { x: MyClass; y: number }; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type '{ x: this; y: number; }', but here has type '{ x: MyClass; y: number; }'. + var t: { x: ContainingThis; y: number }; } } @@ -18,6 +17,8 @@ tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(7,13): e var obj = { f() { return this.spaaace; + ~~~~~~~ +!!! error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'. } }; var obj: { f: () => any; }; diff --git a/tests/baselines/reference/thisInObjectLiterals.js b/tests/baselines/reference/thisInObjectLiterals.js index 6c8380060a7..6331f12105d 100644 --- a/tests/baselines/reference/thisInObjectLiterals.js +++ b/tests/baselines/reference/thisInObjectLiterals.js @@ -3,9 +3,10 @@ class MyClass { t: number; fn() { + type ContainingThis = this; //type of 'this' in an object literal is the containing scope's this var t = { x: this, y: this.t }; - var t: { x: MyClass; y: number }; + var t: { x: ContainingThis; y: number }; } } diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols b/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols index 12d3b2db31e..6afdd73f77f 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols @@ -70,6 +70,7 @@ class A { a: function() { return this; }, >a : Symbol(a, Decl(thisInPropertyBoundDeclarations.ts, 33, 13)) +>this : Symbol(__object, Decl(thisInPropertyBoundDeclarations.ts, 33, 11)) }; @@ -79,6 +80,7 @@ class A { return { a: function() { return this; }, >a : Symbol(a, Decl(thisInPropertyBoundDeclarations.ts, 38, 16)) +>this : Symbol(__object, Decl(thisInPropertyBoundDeclarations.ts, 38, 14)) }; }; diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.types b/tests/baselines/reference/thisInPropertyBoundDeclarations.types index b783c5c1b5f..7c2b28bfb3e 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.types +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.types @@ -84,9 +84,9 @@ class A { >{ a: function() { return this; }, } : { a: () => any; } a: function() { return this; }, ->a : () => any ->function() { return this; } : () => any ->this : any +>a : () => { a: any; } +>function() { return this; } : () => { a: any; } +>this : { a: () => any; } }; @@ -98,9 +98,9 @@ class A { >{ a: function() { return this; }, } : { a: () => any; } a: function() { return this; }, ->a : () => any ->function() { return this; } : () => any ->this : any +>a : () => { a: any; } +>function() { return this; } : () => { a: any; } +>this : { a: () => any; } }; }; diff --git a/tests/baselines/reference/thisTypeInFunctions2.js b/tests/baselines/reference/thisTypeInFunctions2.js index f52438a19ab..45b26fe84d8 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.js +++ b/tests/baselines/reference/thisTypeInFunctions2.js @@ -33,15 +33,14 @@ extend1({ }); extend2({ init() { - this // this: any because the contextual signature of init doesn't specify this' type + this // this: containing object literal type this.mine - this.willDestroy + //this.willDestroy }, mine: 13, foo() { - this // this: any because of the string indexer + this // this: containing object literal type this.mine - this.willDestroy } }); @@ -70,15 +69,14 @@ extend1({ }); extend2({ init: function () { - this; // this: any because the contextual signature of init doesn't specify this' type + this; // this: containing object literal type this.mine; - this.willDestroy; + //this.willDestroy }, mine: 13, foo: function () { - this; // this: any because of the string indexer + this; // this: containing object literal type this.mine; - this.willDestroy; } }); simple({ diff --git a/tests/baselines/reference/thisTypeInFunctions2.symbols b/tests/baselines/reference/thisTypeInFunctions2.symbols index 5cc26e3ad43..d9d0be723b6 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.symbols +++ b/tests/baselines/reference/thisTypeInFunctions2.symbols @@ -89,9 +89,15 @@ extend2({ init() { >init : Symbol(init, Decl(thisTypeInFunctions2.ts, 32, 9)) - this // this: any because the contextual signature of init doesn't specify this' type + this // this: containing object literal type +>this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 32, 8)) + this.mine - this.willDestroy +>this.mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) +>this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 32, 8)) +>mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) + + //this.willDestroy }, mine: 13, >mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) @@ -99,9 +105,13 @@ extend2({ foo() { >foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 38, 13)) - this // this: any because of the string indexer + this // this: containing object literal type +>this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 32, 8)) + this.mine - this.willDestroy +>this.mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) +>this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 32, 8)) +>mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) } }); @@ -109,17 +119,20 @@ simple({ >simple : Symbol(simple, Decl(thisTypeInFunctions2.ts, 17, 57)) foo(n) { ->foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 46, 8)) ->n : Symbol(n, Decl(thisTypeInFunctions2.ts, 47, 8)) +>foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 45, 8)) +>n : Symbol(n, Decl(thisTypeInFunctions2.ts, 46, 8)) return n.length + this.bar(); >n.length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->n : Symbol(n, Decl(thisTypeInFunctions2.ts, 47, 8)) +>n : Symbol(n, Decl(thisTypeInFunctions2.ts, 46, 8)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>this.bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 48, 6)) +>this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 45, 7)) +>bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 48, 6)) }, bar() { ->bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 49, 6)) +>bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 48, 6)) return 14; } diff --git a/tests/baselines/reference/thisTypeInFunctions2.types b/tests/baselines/reference/thisTypeInFunctions2.types index 3cf6c1d2fae..f79426529ea 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.types +++ b/tests/baselines/reference/thisTypeInFunctions2.types @@ -92,26 +92,22 @@ extend1({ } }); extend2({ ->extend2({ init() { this // this: any because the contextual signature of init doesn't specify this' type this.mine this.willDestroy }, mine: 13, foo() { this // this: any because of the string indexer this.mine this.willDestroy }}) : void +>extend2({ init() { this // this: containing object literal type this.mine //this.willDestroy }, mine: 13, foo() { this // this: containing object literal type this.mine }}) : void >extend2 : (args: IndexedWithoutThis) => void ->{ init() { this // this: any because the contextual signature of init doesn't specify this' type this.mine this.willDestroy }, mine: 13, foo() { this // this: any because of the string indexer this.mine this.willDestroy }} : { init(): void; mine: number; foo(): void; } +>{ init() { this // this: containing object literal type this.mine //this.willDestroy }, mine: 13, foo() { this // this: containing object literal type this.mine }} : { init(): void; mine: number; foo(): void; } init() { >init : () => void - this // this: any because the contextual signature of init doesn't specify this' type ->this : any + this // this: containing object literal type +>this : { init(): void; mine: number; foo(): void; } this.mine ->this.mine : any ->this : any ->mine : any - - this.willDestroy ->this.willDestroy : any ->this : any ->willDestroy : any +>this.mine : number +>this : { init(): void; mine: number; foo(): void; } +>mine : number + //this.willDestroy }, mine: 13, >mine : number @@ -120,39 +116,34 @@ extend2({ foo() { >foo : () => void - this // this: any because of the string indexer ->this : any + this // this: containing object literal type +>this : { init(): void; mine: number; foo(): void; } this.mine ->this.mine : any ->this : any ->mine : any - - this.willDestroy ->this.willDestroy : any ->this : any ->willDestroy : any +>this.mine : number +>this : { init(): void; mine: number; foo(): void; } +>mine : number } }); simple({ >simple({ foo(n) { return n.length + this.bar(); }, bar() { return 14; }}) : void >simple : (arg: SimpleInterface) => void ->{ foo(n) { return n.length + this.bar(); }, bar() { return 14; }} : { foo(n: string): any; bar(): number; } +>{ foo(n) { return n.length + this.bar(); }, bar() { return 14; }} : { foo(n: string): number; bar(): number; } foo(n) { ->foo : (n: string) => any +>foo : (n: string) => number >n : string return n.length + this.bar(); ->n.length + this.bar() : any +>n.length + this.bar() : number >n.length : number >n : string >length : number ->this.bar() : any ->this.bar : any ->this : any ->bar : any +>this.bar() : number +>this.bar : () => number +>this : { foo(n: string): number; bar(): number; } +>bar : () => number }, bar() { diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.symbols b/tests/baselines/reference/thisTypeInObjectLiterals.symbols index af4badf1c0f..ad786a4a247 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.symbols +++ b/tests/baselines/reference/thisTypeInObjectLiterals.symbols @@ -9,11 +9,22 @@ let o = { >m : Symbol(m, Decl(thisTypeInObjectLiterals.ts, 1, 13)) return this.d.length; +>this.d.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) +>this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 0, 7)) +>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + }, f: function() { >f : Symbol(f, Decl(thisTypeInObjectLiterals.ts, 4, 6)) return this.d.length; +>this.d.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) +>this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 0, 7)) +>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) } } @@ -27,12 +38,22 @@ let mutuallyRecursive = { >start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11)) return this.passthrough(this.a); +>this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) +>this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 10, 23)) +>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) +>this.a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25)) +>this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 10, 23)) +>a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25)) + }, passthrough(n: number) { >passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) >n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 15, 16)) return this.sub1(n); +>this.sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6)) +>this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 10, 23)) +>sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6)) >n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 15, 16)) }, @@ -44,6 +65,9 @@ let mutuallyRecursive = { >n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) return this.passthrough(n - 1); +>this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) +>this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 10, 23)) +>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) >n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) } return n; diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.types b/tests/baselines/reference/thisTypeInObjectLiterals.types index 240cfaa54f9..d5c6d851faf 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.types +++ b/tests/baselines/reference/thisTypeInObjectLiterals.types @@ -1,66 +1,66 @@ === tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts === let o = { ->o : { d: string; m(): any; f: () => any; } ->{ d: "bar", m() { return this.d.length; }, f: function() { return this.d.length; }} : { d: string; m(): any; f: () => any; } +>o : { d: string; m(): number; f: () => number; } +>{ d: "bar", m() { return this.d.length; }, f: function() { return this.d.length; }} : { d: string; m(): number; f: () => number; } d: "bar", >d : string >"bar" : "bar" m() { ->m : () => any +>m : () => number return this.d.length; ->this.d.length : any ->this.d : any ->this : any ->d : any ->length : any +>this.d.length : number +>this.d : string +>this : { d: string; m(): number; f: () => number; } +>d : string +>length : number }, f: function() { ->f : () => any ->function() { return this.d.length; } : () => any +>f : () => number +>function() { return this.d.length; } : () => number return this.d.length; ->this.d.length : any ->this.d : any ->this : any ->d : any ->length : any +>this.d.length : number +>this.d : string +>this : { d: string; m(): number; f: () => number; } +>d : string +>length : number } } let mutuallyRecursive = { ->mutuallyRecursive : { a: number; start(): any; passthrough(n: number): any; sub1(n: number): number; } ->{ a: 100, start() { return this.passthrough(this.a); }, passthrough(n: number) { return this.sub1(n); }, sub1(n: number): number { if (n > 0) { return this.passthrough(n - 1); } return n; }} : { a: number; start(): any; passthrough(n: number): any; sub1(n: number): number; } +>mutuallyRecursive : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } +>{ a: 100, start() { return this.passthrough(this.a); }, passthrough(n: number) { return this.sub1(n); }, sub1(n: number): number { if (n > 0) { return this.passthrough(n - 1); } return n; }} : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } a: 100, >a : number >100 : 100 start() { ->start : () => any +>start : () => number return this.passthrough(this.a); ->this.passthrough(this.a) : any ->this.passthrough : any ->this : any ->passthrough : any ->this.a : any ->this : any ->a : any +>this.passthrough(this.a) : number +>this.passthrough : (n: number) => number +>this : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } +>passthrough : (n: number) => number +>this.a : number +>this : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } +>a : number }, passthrough(n: number) { ->passthrough : (n: number) => any +>passthrough : (n: number) => number >n : number return this.sub1(n); ->this.sub1(n) : any ->this.sub1 : any ->this : any ->sub1 : any +>this.sub1(n) : number +>this.sub1 : (n: number) => number +>this : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } +>sub1 : (n: number) => number >n : number }, @@ -74,10 +74,10 @@ let mutuallyRecursive = { >0 : 0 return this.passthrough(n - 1); ->this.passthrough(n - 1) : any ->this.passthrough : any ->this : any ->passthrough : any +>this.passthrough(n - 1) : number +>this.passthrough : (n: number) => number +>this : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } +>passthrough : (n: number) => number >n - 1 : number >n : number >1 : 1 @@ -88,10 +88,10 @@ let mutuallyRecursive = { } var i: number = mutuallyRecursive.start(); >i : number ->mutuallyRecursive.start() : any ->mutuallyRecursive.start : () => any ->mutuallyRecursive : { a: number; start(): any; passthrough(n: number): any; sub1(n: number): number; } ->start : () => any +>mutuallyRecursive.start() : number +>mutuallyRecursive.start : () => number +>mutuallyRecursive : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } +>start : () => number interface I { >I : I @@ -113,5 +113,5 @@ interface I { var impl: I = mutuallyRecursive; >impl : I >I : I ->mutuallyRecursive : { a: number; start(): any; passthrough(n: number): any; sub1(n: number): number; } +>mutuallyRecursive : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } diff --git a/tests/baselines/reference/throwInEnclosingStatements.symbols b/tests/baselines/reference/throwInEnclosingStatements.symbols index 63ed9dde578..94f7baee021 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.symbols +++ b/tests/baselines/reference/throwInEnclosingStatements.symbols @@ -89,6 +89,7 @@ var aa = { >biz : Symbol(biz, Decl(throwInEnclosingStatements.ts, 41, 10)) throw this; +>this : Symbol(__object, Decl(throwInEnclosingStatements.ts, 40, 8)) } } diff --git a/tests/baselines/reference/throwInEnclosingStatements.types b/tests/baselines/reference/throwInEnclosingStatements.types index 2d99ac435ae..d859bbd6392 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.types +++ b/tests/baselines/reference/throwInEnclosingStatements.types @@ -104,7 +104,7 @@ var aa = { >biz : () => void throw this; ->this : any +>this : { id: number; biz(): void; } } } diff --git a/tests/baselines/reference/underscoreTest1.symbols b/tests/baselines/reference/underscoreTest1.symbols index 89815bd2371..018633344eb 100644 --- a/tests/baselines/reference/underscoreTest1.symbols +++ b/tests/baselines/reference/underscoreTest1.symbols @@ -395,10 +395,16 @@ var buttonView = { onClick: function () { alert('clicked: ' + this.label); }, >onClick : Symbol(onClick, Decl(underscoreTest1_underscoreTests.ts, 97, 24)) >alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14)) +>this.label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) +>this : Symbol(__object, Decl(underscoreTest1_underscoreTests.ts, 96, 16)) +>label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) onHover: function () { alert('hovering: ' + this.label); } >onHover : Symbol(onHover, Decl(underscoreTest1_underscoreTests.ts, 98, 62)) >alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14)) +>this.label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) +>this : Symbol(__object, Decl(underscoreTest1_underscoreTests.ts, 96, 16)) +>label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) }; _.bindAll(buttonView); diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 97e064fb12c..0af9b55d25a 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -827,9 +827,9 @@ var buttonView = { >alert : (x: string) => void >'clicked: ' + this.label : string >'clicked: ' : "clicked: " ->this.label : any ->this : any ->label : any +>this.label : string +>this : { label: string; onClick: () => void; onHover: () => void; } +>label : string onHover: function () { alert('hovering: ' + this.label); } >onHover : () => void @@ -838,9 +838,9 @@ var buttonView = { >alert : (x: string) => void >'hovering: ' + this.label : string >'hovering: ' : "hovering: " ->this.label : any ->this : any ->label : any +>this.label : string +>this : { label: string; onClick: () => void; onHover: () => void; } +>label : string }; _.bindAll(buttonView); From 27346b13d039a694ff815db81ba6f6df5667fe2e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 16 Feb 2017 20:22:46 -0800 Subject: [PATCH 020/167] Accept new baselines --- tests/baselines/reference/fatarrowfunctions.symbols | 2 +- .../reference/fatarrowfunctionsInFunctions.symbols | 2 +- tests/baselines/reference/objectSpread.symbols | 2 +- tests/baselines/reference/selfInLambdas.symbols | 4 ++-- tests/baselines/reference/thisBinding2.symbols | 2 +- .../reference/thisTypeInObjectLiterals.symbols | 12 ++++++------ .../reference/throwInEnclosingStatements.symbols | 2 +- tests/baselines/reference/underscoreTest1.symbols | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/baselines/reference/fatarrowfunctions.symbols b/tests/baselines/reference/fatarrowfunctions.symbols index 1e5fb4f3178..25213a9bbf8 100644 --- a/tests/baselines/reference/fatarrowfunctions.symbols +++ b/tests/baselines/reference/fatarrowfunctions.symbols @@ -165,7 +165,7 @@ var messenger = { >setTimeout : Symbol(setTimeout, Decl(fatarrowfunctions.ts, 34, 1)) >this.message.toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) >this.message : Symbol(message, Decl(fatarrowfunctions.ts, 38, 17)) ->this : Symbol(__object, Decl(fatarrowfunctions.ts, 38, 15)) +>this : Symbol(messenger, Decl(fatarrowfunctions.ts, 38, 15)) >message : Symbol(message, Decl(fatarrowfunctions.ts, 38, 17)) >toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) } diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols b/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols index f1123f4aa96..977dd39460d 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols +++ b/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols @@ -16,7 +16,7 @@ var messenger = { var _self = this; >_self : Symbol(_self, Decl(fatarrowfunctionsInFunctions.ts, 5, 11)) ->this : Symbol(__object, Decl(fatarrowfunctionsInFunctions.ts, 2, 15)) +>this : Symbol(messenger, Decl(fatarrowfunctionsInFunctions.ts, 2, 15)) setTimeout(function() { >setTimeout : Symbol(setTimeout, Decl(fatarrowfunctionsInFunctions.ts, 0, 0)) diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 3487f757aeb..a734066d5e7 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -201,7 +201,7 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } } >c : Symbol(c, Decl(objectSpread.ts, 45, 3)) >plus : Symbol(plus, Decl(objectSpread.ts, 49, 48)) >this.p : Symbol(C.p, Decl(objectSpread.ts, 44, 9)) ->this : Symbol(__object, Decl(objectSpread.ts, 49, 40)) +>this : Symbol(cplus, Decl(objectSpread.ts, 49, 40)) >p : Symbol(C.p, Decl(objectSpread.ts, 44, 9)) cplus.plus(); diff --git a/tests/baselines/reference/selfInLambdas.symbols b/tests/baselines/reference/selfInLambdas.symbols index 6f91adefcc1..0a51113710b 100644 --- a/tests/baselines/reference/selfInLambdas.symbols +++ b/tests/baselines/reference/selfInLambdas.symbols @@ -38,13 +38,13 @@ var o = { this.counter++ >this.counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) ->this : Symbol(__object, Decl(selfInLambdas.ts, 10, 7)) +>this : Symbol(o, Decl(selfInLambdas.ts, 10, 7)) >counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) var f = () => this.counter; >f : Symbol(f, Decl(selfInLambdas.ts, 18, 15)) >this.counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) ->this : Symbol(__object, Decl(selfInLambdas.ts, 10, 7)) +>this : Symbol(o, Decl(selfInLambdas.ts, 10, 7)) >counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) } diff --git a/tests/baselines/reference/thisBinding2.symbols b/tests/baselines/reference/thisBinding2.symbols index 507b7e48419..f8436f5248b 100644 --- a/tests/baselines/reference/thisBinding2.symbols +++ b/tests/baselines/reference/thisBinding2.symbols @@ -51,7 +51,7 @@ var messenger = { >setTimeout : Symbol(setTimeout, Decl(thisBinding2.ts, 12, 1)) >x : Symbol(x, Decl(thisBinding2.ts, 17, 37)) >this.message : Symbol(message, Decl(thisBinding2.ts, 14, 17)) ->this : Symbol(__object, Decl(thisBinding2.ts, 14, 15)) +>this : Symbol(messenger, Decl(thisBinding2.ts, 14, 15)) >message : Symbol(message, Decl(thisBinding2.ts, 14, 17)) } }; diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.symbols b/tests/baselines/reference/thisTypeInObjectLiterals.symbols index ad786a4a247..fd6d6ecebd5 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.symbols +++ b/tests/baselines/reference/thisTypeInObjectLiterals.symbols @@ -11,7 +11,7 @@ let o = { return this.d.length; >this.d.length : Symbol(String.length, Decl(lib.d.ts, --, --)) >this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) ->this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 0, 7)) +>this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 0, 7)) >d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) @@ -22,7 +22,7 @@ let o = { return this.d.length; >this.d.length : Symbol(String.length, Decl(lib.d.ts, --, --)) >this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) ->this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 0, 7)) +>this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 0, 7)) >d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) } @@ -39,10 +39,10 @@ let mutuallyRecursive = { return this.passthrough(this.a); >this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) ->this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 10, 23)) +>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23)) >passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) >this.a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25)) ->this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 10, 23)) +>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23)) >a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25)) }, @@ -52,7 +52,7 @@ let mutuallyRecursive = { return this.sub1(n); >this.sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6)) ->this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 10, 23)) +>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23)) >sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6)) >n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 15, 16)) @@ -66,7 +66,7 @@ let mutuallyRecursive = { return this.passthrough(n - 1); >this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) ->this : Symbol(__object, Decl(thisTypeInObjectLiterals.ts, 10, 23)) +>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23)) >passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) >n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) } diff --git a/tests/baselines/reference/throwInEnclosingStatements.symbols b/tests/baselines/reference/throwInEnclosingStatements.symbols index 94f7baee021..36dcd3cfcbd 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.symbols +++ b/tests/baselines/reference/throwInEnclosingStatements.symbols @@ -89,7 +89,7 @@ var aa = { >biz : Symbol(biz, Decl(throwInEnclosingStatements.ts, 41, 10)) throw this; ->this : Symbol(__object, Decl(throwInEnclosingStatements.ts, 40, 8)) +>this : Symbol(aa, Decl(throwInEnclosingStatements.ts, 40, 8)) } } diff --git a/tests/baselines/reference/underscoreTest1.symbols b/tests/baselines/reference/underscoreTest1.symbols index 459674cdbe8..3b578be8165 100644 --- a/tests/baselines/reference/underscoreTest1.symbols +++ b/tests/baselines/reference/underscoreTest1.symbols @@ -396,14 +396,14 @@ var buttonView = { >onClick : Symbol(onClick, Decl(underscoreTest1_underscoreTests.ts, 97, 24)) >alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14)) >this.label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) ->this : Symbol(__object, Decl(underscoreTest1_underscoreTests.ts, 96, 16)) +>this : Symbol(buttonView, Decl(underscoreTest1_underscoreTests.ts, 96, 16)) >label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) onHover: function () { alert('hovering: ' + this.label); } >onHover : Symbol(onHover, Decl(underscoreTest1_underscoreTests.ts, 98, 62)) >alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14)) >this.label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) ->this : Symbol(__object, Decl(underscoreTest1_underscoreTests.ts, 96, 16)) +>this : Symbol(buttonView, Decl(underscoreTest1_underscoreTests.ts, 96, 16)) >label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) }; From 0eec41ee63decfadfdc81f4323dc987a31b0b718 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 16 Feb 2017 22:53:41 -0800 Subject: [PATCH 021/167] Simplify helpers --- src/compiler/transformers/destructuring.ts | 2 +- src/compiler/utilities.ts | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/compiler/transformers/destructuring.ts b/src/compiler/transformers/destructuring.ts index b4473e6a261..48403cc89db 100644 --- a/src/compiler/transformers/destructuring.ts +++ b/src/compiler/transformers/destructuring.ts @@ -42,7 +42,7 @@ namespace ts { let value: Expression; if (isDestructuringAssignment(node)) { value = node.right; - while (isEmptyObjectLiteralOrArrayLiteral(node.left)) { + while (isEmptyArrayLiteral(node.left) || isEmptyObjectLiteral(node.left)) { if (isDestructuringAssignment(value)) { location = node = value; value = node.right; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 97137090d38..34c7a0bdb02 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3093,15 +3093,14 @@ namespace ts { (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node); } - export function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean { - const kind = expression.kind; - if (kind === SyntaxKind.ObjectLiteralExpression) { - return (expression).properties.length === 0; - } - if (kind === SyntaxKind.ArrayLiteralExpression) { - return (expression).elements.length === 0; - } - return false; + export function isEmptyObjectLiteral(expression: Node): boolean { + return expression.kind === SyntaxKind.ObjectLiteralExpression && + (expression).properties.length === 0; + } + + export function isEmptyArrayLiteral(expression: Node): boolean { + return expression.kind === SyntaxKind.ArrayLiteralExpression && + (expression).elements.length === 0; } export function getLocalSymbolForExportDefault(symbol: Symbol) { From e3a0687327128c4cce55b8ce448ce8ad7d3fca9b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 17 Feb 2017 06:56:58 -0800 Subject: [PATCH 022/167] Contextual this in 'obj.xxx = function(...)' or 'obj[xxx] = function(...)' --- src/compiler/checker.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3208d303ab0..9fb71884c51 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11518,6 +11518,14 @@ namespace ts { // for 'this' is the type of the object literal itself. return checkExpressionCached(containingLiteral); } + // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the + // contextual type for 'this' is 'obj'. + if (func.parent.kind === SyntaxKind.BinaryExpression && (func.parent).operatorToken.kind === SyntaxKind.EqualsToken) { + const target = (func.parent).left; + if (target.kind === SyntaxKind.PropertyAccessExpression || target.kind === SyntaxKind.ElementAccessExpression) { + return checkExpressionCached((target).expression); + } + } } return undefined; } From 1d339de34230493b8b521d3335d2ca8e0e170b00 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Sat, 18 Feb 2017 14:17:12 -0800 Subject: [PATCH 023/167] Fix #14171: Recognize property assignements to `module.export` aliases as exports --- src/compiler/binder.ts | 46 +- src/compiler/utilities.ts | 15 + .../reference/moduleExportAlias.symbols | 227 ++++++++++ .../reference/moduleExportAlias.types | 395 ++++++++++++++++++ .../conformance/salsa/moduleExportAlias.ts | 79 ++++ 5 files changed, 761 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/moduleExportAlias.symbols create mode 100644 tests/baselines/reference/moduleExportAlias.types create mode 100644 tests/cases/conformance/salsa/moduleExportAlias.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4837b673132..5aafa13da9e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2227,7 +2227,42 @@ namespace ts { declareSymbol(file.symbol.exports, file.symbol, node.left, SymbolFlags.Property | SymbolFlags.Export, SymbolFlags.None); } + function isExportsOrModuleExportsOrAlias(node: Node): boolean { + return isExportsIdentifier(node) || + isModuleExportsPropertyAccessExpression(node) || + isNameOfExportsOrModuleExportsAliasDeclaration(node); + } + + function isNameOfExportsOrModuleExportsAliasDeclaration(node: Node) { + if (node.kind === SyntaxKind.Identifier) { + const symbol = container.locals.get((node).text); + if (symbol && symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.VariableDeclaration) { + const declaration = symbol.valueDeclaration as VariableDeclaration; + if (declaration.initializer) { + return isExportsOrModuleExportsOrAliasOrAssignemnt(declaration.initializer); + } + } + } + return false; + } + + function isExportsOrModuleExportsOrAliasOrAssignemnt(node: Node): boolean { + return isExportsOrModuleExportsOrAlias(node) || + (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true) && (isExportsOrModuleExportsOrAliasOrAssignemnt(node.left) || isExportsOrModuleExportsOrAliasOrAssignemnt(node.right))); + } + function bindModuleExportsAssignment(node: BinaryExpression) { + // A common practice in node modules is to set 'export = module.exports = {}', this ensures that 'exports' + // is still pointing to 'module.exports'. + // We do not want to consider this as 'export=' since a module can have only one of these. + // Similarlly we do not want to treat 'module.exports = exports' as an 'export='. + const assignedExpression = getRightMostAssignedExpression(node.right); + if (isEmptyObjectLiteral(assignedExpression) || isExportsOrModuleExportsOrAlias(assignedExpression)) { + // Mark it as a module in case there are no other exports in the file + setCommonJsModuleIndicator(node); + return; + } + // 'module.exports = expr' assignment setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node, SymbolFlags.Property | SymbolFlags.Export | SymbolFlags.ValueModule, SymbolFlags.None); @@ -2284,11 +2319,20 @@ namespace ts { leftSideOfAssignment.parent = node; target.parent = leftSideOfAssignment; - bindPropertyAssignment(target.text, leftSideOfAssignment, /*isPrototypeProperty*/ false); + if (isNameOfExportsOrModuleExportsAliasDeclaration(target)) { + // This can be an alias for the 'exports' or 'module.exports' names, e.g. + // var util = module.exports; + // util.property = function ... + bindExportsPropertyAssignment(node); + } + else { + bindPropertyAssignment(target.text, leftSideOfAssignment, /*isPrototypeProperty*/ false); + } } function bindPropertyAssignment(functionName: string, propertyAccessExpression: PropertyAccessExpression, isPrototypeProperty: boolean) { let targetSymbol = container.locals.get(functionName); + if (targetSymbol && isDeclarationOfFunctionOrClassExpression(targetSymbol)) { targetSymbol = (targetSymbol.valueDeclaration as VariableDeclaration).initializer.symbol; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 34c7a0bdb02..51613c14b6f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1425,6 +1425,21 @@ namespace ts { return false; } + export function getRightMostAssignedExpression(node: Node) { + while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + node = node.right; + } + return node; + } + + export function isExportsIdentifier(node: Node) { + return isIdentifier(node) && node.text === "exports"; + } + + export function isModuleExportsPropertyAccessExpression(node: Node) { + return isPropertyAccessExpression(node) && isIdentifier(node.expression) && node.expression.text === "module" && node.name.text === "exports"; + } + /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind { diff --git a/tests/baselines/reference/moduleExportAlias.symbols b/tests/baselines/reference/moduleExportAlias.symbols new file mode 100644 index 00000000000..b78b6e214f3 --- /dev/null +++ b/tests/baselines/reference/moduleExportAlias.symbols @@ -0,0 +1,227 @@ +=== tests/cases/conformance/salsa/a.ts === + +import b = require("./b.js"); +>b : Symbol(b, Decl(a.ts, 0, 0)) + +b.func1; +>b.func1 : Symbol(b.func1, Decl(b.js, 0, 27)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func1 : Symbol(b.func1, Decl(b.js, 0, 27)) + +b.func2; +>b.func2 : Symbol(b.func2, Decl(b.js, 1, 37)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func2 : Symbol(b.func2, Decl(b.js, 1, 37)) + +b.func3; +>b.func3 : Symbol(b.func3, Decl(b.js, 4, 40)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func3 : Symbol(b.func3, Decl(b.js, 4, 40)) + +b.func4; +>b.func4 : Symbol(b.func4, Decl(b.js, 5, 43)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func4 : Symbol(b.func4, Decl(b.js, 5, 43)) + +b.func5; +>b.func5 : Symbol(b.func5, Decl(b.js, 8, 57)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func5 : Symbol(b.func5, Decl(b.js, 8, 57)) + +b.func6; +>b.func6 : Symbol(b.func6, Decl(b.js, 11, 57)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func6 : Symbol(b.func6, Decl(b.js, 11, 57)) + +b.func7; +>b.func7 : Symbol(b.func7, Decl(b.js, 15, 60)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func7 : Symbol(b.func7, Decl(b.js, 15, 60)) + +b.func8; +>b.func8 : Symbol(b.func8, Decl(b.js, 18, 67)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func8 : Symbol(b.func8, Decl(b.js, 18, 67)) + +b.func9; +>b.func9 : Symbol(b.func9, Decl(b.js, 21, 62)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func9 : Symbol(b.func9, Decl(b.js, 21, 62)) + +b.func10; +>b.func10 : Symbol(b.func10, Decl(b.js, 24, 62)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func10 : Symbol(b.func10, Decl(b.js, 24, 62)) + +b.func11; +>b.func11 : Symbol(b.func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func11 : Symbol(b.func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) + +b.func12; +>b.func12 : Symbol(b.func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func12 : Symbol(b.func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) + +b.func13; +>b.func13 : Symbol(b.func13, Decl(b.js, 35, 30)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func13 : Symbol(b.func13, Decl(b.js, 35, 30)) + +b.func14; +>b.func14 : Symbol(b.func14, Decl(b.js, 36, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func14 : Symbol(b.func14, Decl(b.js, 36, 33)) + +b.func15; +>b.func15 : Symbol(b.func15, Decl(b.js, 39, 30)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func15 : Symbol(b.func15, Decl(b.js, 39, 30)) + +b.func16; +>b.func16 : Symbol(b.func16, Decl(b.js, 40, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func16 : Symbol(b.func16, Decl(b.js, 40, 33)) + +b.func17; +>b.func17 : Symbol(b.func17, Decl(b.js, 43, 30)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func17 : Symbol(b.func17, Decl(b.js, 43, 30)) + +b.func18; +>b.func18 : Symbol(b.func18, Decl(b.js, 44, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func18 : Symbol(b.func18, Decl(b.js, 44, 33)) + +b.func19; +>b.func19 : Symbol(b.func19, Decl(b.js, 47, 20)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func19 : Symbol(b.func19, Decl(b.js, 47, 20)) + +b.func20; +>b.func20 : Symbol(b.func20, Decl(b.js, 48, 33)) +>b : Symbol(b, Decl(a.ts, 0, 0)) +>func20 : Symbol(b.func20, Decl(b.js, 48, 33)) + + +=== tests/cases/conformance/salsa/b.js === +var exportsAlias = exports; +>exportsAlias : Symbol(exportsAlias, Decl(b.js, 0, 3)) + +exportsAlias.func1 = function () { }; +>exportsAlias : Symbol(exportsAlias, Decl(b.js, 0, 3)) + +exports.func2 = function () { }; +>exports : Symbol(func2, Decl(b.js, 1, 37)) +>func2 : Symbol(func2, Decl(b.js, 1, 37)) + +var moduleExportsAlias = module.exports; +>moduleExportsAlias : Symbol(moduleExportsAlias, Decl(b.js, 4, 3)) + +moduleExportsAlias.func3 = function () { }; +>moduleExportsAlias : Symbol(moduleExportsAlias, Decl(b.js, 4, 3)) + +module.exports.func4 = function () { }; +>module.exports : Symbol(func4, Decl(b.js, 5, 43)) +>func4 : Symbol(func4, Decl(b.js, 5, 43)) + +var multipleDeclarationAlias1 = exports = module.exports; +>multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) + +multipleDeclarationAlias1.func5 = function () { }; +>multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) + +var multipleDeclarationAlias2 = module.exports = exports; +>multipleDeclarationAlias2 : Symbol(multipleDeclarationAlias2, Decl(b.js, 11, 3)) + +multipleDeclarationAlias2.func6 = function () { }; +>multipleDeclarationAlias2 : Symbol(multipleDeclarationAlias2, Decl(b.js, 11, 3)) + +var someOtherVariable; +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +var multipleDeclarationAlias3 = someOtherVariable = exports; +>multipleDeclarationAlias3 : Symbol(multipleDeclarationAlias3, Decl(b.js, 15, 3)) +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +multipleDeclarationAlias3.func7 = function () { }; +>multipleDeclarationAlias3 : Symbol(multipleDeclarationAlias3, Decl(b.js, 15, 3)) + +var multipleDeclarationAlias4 = someOtherVariable = module.exports; +>multipleDeclarationAlias4 : Symbol(multipleDeclarationAlias4, Decl(b.js, 18, 3)) +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +multipleDeclarationAlias4.func8 = function () { }; +>multipleDeclarationAlias4 : Symbol(multipleDeclarationAlias4, Decl(b.js, 18, 3)) + +var multipleDeclarationAlias5 = module.exports = exports = {}; +>multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) + +multipleDeclarationAlias5.func9 = function () { }; +>multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) + +var multipleDeclarationAlias6 = exports = module.exports = {}; +>multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) + +multipleDeclarationAlias6.func10 = function () { }; +>multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) + +exports = module.exports = someOtherVariable = {}; +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +exports.func11 = function () { }; +>exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) +>func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) + +module.exports.func12 = function () { }; +>module.exports : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) +>func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) + +exports = module.exports = someOtherVariable = {}; +>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + +exports.func11 = function () { }; +>exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) +>func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) + +module.exports.func12 = function () { }; +>module.exports : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) +>func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) + +exports = module.exports = {}; +exports.func13 = function () { }; +>exports : Symbol(func13, Decl(b.js, 35, 30)) +>func13 : Symbol(func13, Decl(b.js, 35, 30)) + +module.exports.func14 = function () { }; +>module.exports : Symbol(func14, Decl(b.js, 36, 33)) +>func14 : Symbol(func14, Decl(b.js, 36, 33)) + +exports = module.exports = {}; +exports.func15 = function () { }; +>exports : Symbol(func15, Decl(b.js, 39, 30)) +>func15 : Symbol(func15, Decl(b.js, 39, 30)) + +module.exports.func16 = function () { }; +>module.exports : Symbol(func16, Decl(b.js, 40, 33)) +>func16 : Symbol(func16, Decl(b.js, 40, 33)) + +module.exports = exports = {}; +exports.func17 = function () { }; +>exports : Symbol(func17, Decl(b.js, 43, 30)) +>func17 : Symbol(func17, Decl(b.js, 43, 30)) + +module.exports.func18 = function () { }; +>module.exports : Symbol(func18, Decl(b.js, 44, 33)) +>func18 : Symbol(func18, Decl(b.js, 44, 33)) + +module.exports = {}; +exports.func19 = function () { }; +>exports : Symbol(func19, Decl(b.js, 47, 20)) +>func19 : Symbol(func19, Decl(b.js, 47, 20)) + +module.exports.func20 = function () { }; +>module.exports : Symbol(func20, Decl(b.js, 48, 33)) +>func20 : Symbol(func20, Decl(b.js, 48, 33)) + + diff --git a/tests/baselines/reference/moduleExportAlias.types b/tests/baselines/reference/moduleExportAlias.types new file mode 100644 index 00000000000..2fbc6322955 --- /dev/null +++ b/tests/baselines/reference/moduleExportAlias.types @@ -0,0 +1,395 @@ +=== tests/cases/conformance/salsa/a.ts === + +import b = require("./b.js"); +>b : typeof b + +b.func1; +>b.func1 : () => void +>b : typeof b +>func1 : () => void + +b.func2; +>b.func2 : () => void +>b : typeof b +>func2 : () => void + +b.func3; +>b.func3 : () => void +>b : typeof b +>func3 : () => void + +b.func4; +>b.func4 : () => void +>b : typeof b +>func4 : () => void + +b.func5; +>b.func5 : () => void +>b : typeof b +>func5 : () => void + +b.func6; +>b.func6 : () => void +>b : typeof b +>func6 : () => void + +b.func7; +>b.func7 : () => void +>b : typeof b +>func7 : () => void + +b.func8; +>b.func8 : () => void +>b : typeof b +>func8 : () => void + +b.func9; +>b.func9 : () => void +>b : typeof b +>func9 : () => void + +b.func10; +>b.func10 : () => void +>b : typeof b +>func10 : () => void + +b.func11; +>b.func11 : () => void +>b : typeof b +>func11 : () => void + +b.func12; +>b.func12 : () => void +>b : typeof b +>func12 : () => void + +b.func13; +>b.func13 : () => void +>b : typeof b +>func13 : () => void + +b.func14; +>b.func14 : () => void +>b : typeof b +>func14 : () => void + +b.func15; +>b.func15 : () => void +>b : typeof b +>func15 : () => void + +b.func16; +>b.func16 : () => void +>b : typeof b +>func16 : () => void + +b.func17; +>b.func17 : () => void +>b : typeof b +>func17 : () => void + +b.func18; +>b.func18 : () => void +>b : typeof b +>func18 : () => void + +b.func19; +>b.func19 : () => void +>b : typeof b +>func19 : () => void + +b.func20; +>b.func20 : () => void +>b : typeof b +>func20 : () => void + + +=== tests/cases/conformance/salsa/b.js === +var exportsAlias = exports; +>exportsAlias : any +>exports : any + +exportsAlias.func1 = function () { }; +>exportsAlias.func1 = function () { } : () => void +>exportsAlias.func1 : any +>exportsAlias : any +>func1 : any +>function () { } : () => void + +exports.func2 = function () { }; +>exports.func2 = function () { } : () => void +>exports.func2 : any +>exports : any +>func2 : any +>function () { } : () => void + +var moduleExportsAlias = module.exports; +>moduleExportsAlias : any +>module.exports : any +>module : any +>exports : any + +moduleExportsAlias.func3 = function () { }; +>moduleExportsAlias.func3 = function () { } : () => void +>moduleExportsAlias.func3 : any +>moduleExportsAlias : any +>func3 : any +>function () { } : () => void + +module.exports.func4 = function () { }; +>module.exports.func4 = function () { } : () => void +>module.exports.func4 : any +>module.exports : any +>module : any +>exports : any +>func4 : any +>function () { } : () => void + +var multipleDeclarationAlias1 = exports = module.exports; +>multipleDeclarationAlias1 : any +>exports = module.exports : any +>exports : any +>module.exports : any +>module : any +>exports : any + +multipleDeclarationAlias1.func5 = function () { }; +>multipleDeclarationAlias1.func5 = function () { } : () => void +>multipleDeclarationAlias1.func5 : any +>multipleDeclarationAlias1 : any +>func5 : any +>function () { } : () => void + +var multipleDeclarationAlias2 = module.exports = exports; +>multipleDeclarationAlias2 : any +>module.exports = exports : any +>module.exports : any +>module : any +>exports : any +>exports : any + +multipleDeclarationAlias2.func6 = function () { }; +>multipleDeclarationAlias2.func6 = function () { } : () => void +>multipleDeclarationAlias2.func6 : any +>multipleDeclarationAlias2 : any +>func6 : any +>function () { } : () => void + +var someOtherVariable; +>someOtherVariable : any + +var multipleDeclarationAlias3 = someOtherVariable = exports; +>multipleDeclarationAlias3 : any +>someOtherVariable = exports : any +>someOtherVariable : any +>exports : any + +multipleDeclarationAlias3.func7 = function () { }; +>multipleDeclarationAlias3.func7 = function () { } : () => void +>multipleDeclarationAlias3.func7 : any +>multipleDeclarationAlias3 : any +>func7 : any +>function () { } : () => void + +var multipleDeclarationAlias4 = someOtherVariable = module.exports; +>multipleDeclarationAlias4 : any +>someOtherVariable = module.exports : any +>someOtherVariable : any +>module.exports : any +>module : any +>exports : any + +multipleDeclarationAlias4.func8 = function () { }; +>multipleDeclarationAlias4.func8 = function () { } : () => void +>multipleDeclarationAlias4.func8 : any +>multipleDeclarationAlias4 : any +>func8 : any +>function () { } : () => void + +var multipleDeclarationAlias5 = module.exports = exports = {}; +>multipleDeclarationAlias5 : {} +>module.exports = exports = {} : {} +>module.exports : any +>module : any +>exports : any +>exports = {} : {} +>exports : any +>{} : {} + +multipleDeclarationAlias5.func9 = function () { }; +>multipleDeclarationAlias5.func9 = function () { } : () => void +>multipleDeclarationAlias5.func9 : any +>multipleDeclarationAlias5 : {} +>func9 : any +>function () { } : () => void + +var multipleDeclarationAlias6 = exports = module.exports = {}; +>multipleDeclarationAlias6 : {} +>exports = module.exports = {} : {} +>exports : any +>module.exports = {} : {} +>module.exports : any +>module : any +>exports : any +>{} : {} + +multipleDeclarationAlias6.func10 = function () { }; +>multipleDeclarationAlias6.func10 = function () { } : () => void +>multipleDeclarationAlias6.func10 : any +>multipleDeclarationAlias6 : {} +>func10 : any +>function () { } : () => void + +exports = module.exports = someOtherVariable = {}; +>exports = module.exports = someOtherVariable = {} : {} +>exports : any +>module.exports = someOtherVariable = {} : {} +>module.exports : any +>module : any +>exports : any +>someOtherVariable = {} : {} +>someOtherVariable : any +>{} : {} + +exports.func11 = function () { }; +>exports.func11 = function () { } : () => void +>exports.func11 : any +>exports : any +>func11 : any +>function () { } : () => void + +module.exports.func12 = function () { }; +>module.exports.func12 = function () { } : () => void +>module.exports.func12 : any +>module.exports : any +>module : any +>exports : any +>func12 : any +>function () { } : () => void + +exports = module.exports = someOtherVariable = {}; +>exports = module.exports = someOtherVariable = {} : {} +>exports : any +>module.exports = someOtherVariable = {} : {} +>module.exports : any +>module : any +>exports : any +>someOtherVariable = {} : {} +>someOtherVariable : any +>{} : {} + +exports.func11 = function () { }; +>exports.func11 = function () { } : () => void +>exports.func11 : any +>exports : any +>func11 : any +>function () { } : () => void + +module.exports.func12 = function () { }; +>module.exports.func12 = function () { } : () => void +>module.exports.func12 : any +>module.exports : any +>module : any +>exports : any +>func12 : any +>function () { } : () => void + +exports = module.exports = {}; +>exports = module.exports = {} : {} +>exports : any +>module.exports = {} : {} +>module.exports : any +>module : any +>exports : any +>{} : {} + +exports.func13 = function () { }; +>exports.func13 = function () { } : () => void +>exports.func13 : any +>exports : any +>func13 : any +>function () { } : () => void + +module.exports.func14 = function () { }; +>module.exports.func14 = function () { } : () => void +>module.exports.func14 : any +>module.exports : any +>module : any +>exports : any +>func14 : any +>function () { } : () => void + +exports = module.exports = {}; +>exports = module.exports = {} : {} +>exports : any +>module.exports = {} : {} +>module.exports : any +>module : any +>exports : any +>{} : {} + +exports.func15 = function () { }; +>exports.func15 = function () { } : () => void +>exports.func15 : any +>exports : any +>func15 : any +>function () { } : () => void + +module.exports.func16 = function () { }; +>module.exports.func16 = function () { } : () => void +>module.exports.func16 : any +>module.exports : any +>module : any +>exports : any +>func16 : any +>function () { } : () => void + +module.exports = exports = {}; +>module.exports = exports = {} : {} +>module.exports : any +>module : any +>exports : any +>exports = {} : {} +>exports : any +>{} : {} + +exports.func17 = function () { }; +>exports.func17 = function () { } : () => void +>exports.func17 : any +>exports : any +>func17 : any +>function () { } : () => void + +module.exports.func18 = function () { }; +>module.exports.func18 = function () { } : () => void +>module.exports.func18 : any +>module.exports : any +>module : any +>exports : any +>func18 : any +>function () { } : () => void + +module.exports = {}; +>module.exports = {} : {} +>module.exports : any +>module : any +>exports : any +>{} : {} + +exports.func19 = function () { }; +>exports.func19 = function () { } : () => void +>exports.func19 : any +>exports : any +>func19 : any +>function () { } : () => void + +module.exports.func20 = function () { }; +>module.exports.func20 = function () { } : () => void +>module.exports.func20 : any +>module.exports : any +>module : any +>exports : any +>func20 : any +>function () { } : () => void + + diff --git a/tests/cases/conformance/salsa/moduleExportAlias.ts b/tests/cases/conformance/salsa/moduleExportAlias.ts new file mode 100644 index 00000000000..60220271a57 --- /dev/null +++ b/tests/cases/conformance/salsa/moduleExportAlias.ts @@ -0,0 +1,79 @@ +// @allowJS: true +// @noEmit: true + +// @filename: a.ts +import b = require("./b.js"); +b.func1; +b.func2; +b.func3; +b.func4; +b.func5; +b.func6; +b.func7; +b.func8; +b.func9; +b.func10; +b.func11; +b.func12; +b.func13; +b.func14; +b.func15; +b.func16; +b.func17; +b.func18; +b.func19; +b.func20; + + +// @filename: b.js +var exportsAlias = exports; +exportsAlias.func1 = function () { }; +exports.func2 = function () { }; + +var moduleExportsAlias = module.exports; +moduleExportsAlias.func3 = function () { }; +module.exports.func4 = function () { }; + +var multipleDeclarationAlias1 = exports = module.exports; +multipleDeclarationAlias1.func5 = function () { }; + +var multipleDeclarationAlias2 = module.exports = exports; +multipleDeclarationAlias2.func6 = function () { }; + +var someOtherVariable; +var multipleDeclarationAlias3 = someOtherVariable = exports; +multipleDeclarationAlias3.func7 = function () { }; + +var multipleDeclarationAlias4 = someOtherVariable = module.exports; +multipleDeclarationAlias4.func8 = function () { }; + +var multipleDeclarationAlias5 = module.exports = exports = {}; +multipleDeclarationAlias5.func9 = function () { }; + +var multipleDeclarationAlias6 = exports = module.exports = {}; +multipleDeclarationAlias6.func10 = function () { }; + +exports = module.exports = someOtherVariable = {}; +exports.func11 = function () { }; +module.exports.func12 = function () { }; + +exports = module.exports = someOtherVariable = {}; +exports.func11 = function () { }; +module.exports.func12 = function () { }; + +exports = module.exports = {}; +exports.func13 = function () { }; +module.exports.func14 = function () { }; + +exports = module.exports = {}; +exports.func15 = function () { }; +module.exports.func16 = function () { }; + +module.exports = exports = {}; +exports.func17 = function () { }; +module.exports.func18 = function () { }; + +module.exports = {}; +exports.func19 = function () { }; +module.exports.func20 = function () { }; + From 5ed5e5fd9432a5104de7a1e3459d0a6ea5951661 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Sun, 19 Feb 2017 18:38:09 +0100 Subject: [PATCH 024/167] Add CatchClause to VariableDeclaration.parent --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index de42d5d9745..234e5570029 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -651,7 +651,7 @@ export interface VariableDeclaration extends Declaration { kind: SyntaxKind.VariableDeclaration; - parent?: VariableDeclarationList; + parent?: VariableDeclarationList | CatchClause; name: BindingName; // Declared variable name type?: TypeNode; // Optional type annotation initializer?: Expression; // Optional initializer From 077862736d00f9184ae89ae08f46f7b52333ebbd Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Sun, 19 Feb 2017 21:26:04 +0100 Subject: [PATCH 025/167] Add parent type for nodes where possible --- src/compiler/types.ts | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 234e5570029..3d93907ae98 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -624,6 +624,7 @@ export interface TypeParameterDeclaration extends Declaration { kind: SyntaxKind.TypeParameter; + parent?: DeclarationWithTypeParameters; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -659,11 +660,13 @@ export interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; + parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } export interface ParameterDeclaration extends Declaration { kind: SyntaxKind.Parameter; + parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; // Present on rest parameter name: BindingName; // Declared parameter name questionToken?: QuestionToken; // Present on optional parameter @@ -673,6 +676,7 @@ export interface BindingElement extends Declaration { kind: SyntaxKind.BindingElement; + parent?: BindingPattern; propertyName?: PropertyName; // Binding property name (in object binding pattern) dotDotDotToken?: DotDotDotToken; // Present on rest element (in object binding pattern) name: BindingName; // Declared binding element name @@ -754,11 +758,13 @@ export interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } export interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } @@ -1327,14 +1333,17 @@ export interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; + parent?: TemplateExpression; } export interface TemplateMiddle extends LiteralLikeNode { kind: SyntaxKind.TemplateMiddle; + parent?: TemplateSpan; } export interface TemplateTail extends LiteralLikeNode { kind: SyntaxKind.TemplateTail; + parent?: TemplateSpan; } export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; @@ -1349,6 +1358,7 @@ // The template literal must have kind TemplateMiddleLiteral or TemplateTailLiteral. export interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; + parent?: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } @@ -1503,6 +1513,7 @@ /// The opening element of a ... JsxElement export interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; + parent?: JsxElement; tagName: JsxTagNameExpression; attributes: JsxAttributes; } @@ -1516,6 +1527,7 @@ export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; + parent?: JsxOpeningLikeElement; name: Identifier; /// JSX attribute initializers are optional; is sugar for initializer?: StringLiteral | JsxExpression; @@ -1523,22 +1535,26 @@ export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; + parent?: JsxOpeningLikeElement; expression: Expression; } export interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; + parent?: JsxElement; tagName: JsxTagNameExpression; } export interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + parent?: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } export interface JsxText extends Node { kind: SyntaxKind.JsxText; + parent?: JsxElement; } export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; @@ -1680,17 +1696,20 @@ export interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; + parent?: SwitchStatement; clauses: NodeArray; } export interface CaseClause extends Node { kind: SyntaxKind.CaseClause; + parent?: CaseBlock; expression: Expression; statements: NodeArray; } export interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; + parent?: CaseBlock; statements: NodeArray; } @@ -1716,6 +1735,7 @@ export interface CatchClause extends Node { kind: SyntaxKind.CatchClause; + parent?: TryStatement; variableDeclaration: VariableDeclaration; block: Block; } @@ -1759,6 +1779,7 @@ export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; + parent?: InterfaceDeclaration | ClassDeclaration | ClassExpression; token: SyntaxKind; types?: NodeArray; } @@ -1772,6 +1793,7 @@ export interface EnumMember extends Declaration { kind: SyntaxKind.EnumMember; + parent?: EnumDeclaration; // This does include ComputedPropertyName, but the parser will give an error // if it parses a ComputedPropertyName in an EnumMember name: PropertyName; @@ -1790,7 +1812,8 @@ export interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; - name: Identifier | StringLiteral; + parent?: ModuleBody | SourceFile; + name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; } @@ -1810,6 +1833,7 @@ export interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; + parent?: ModuleDeclaration; statements: NodeArray; } @@ -1817,6 +1841,7 @@ export interface ImportEqualsDeclaration extends DeclarationStatement { kind: SyntaxKind.ImportEqualsDeclaration; + parent?: SourceFile | ModuleBlock; name: Identifier; // 'EntityName' for an internal module reference, 'ExternalModuleReference' for an external @@ -1826,6 +1851,7 @@ export interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; + parent?: ImportEqualsDeclaration; expression?: Expression; } @@ -1835,6 +1861,7 @@ // ImportClause information is shown at its declaration below. export interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; + parent?: SourceFile | ModuleBlock; importClause?: ImportClause; moduleSpecifier: Expression; } @@ -1849,12 +1876,14 @@ // import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} export interface ImportClause extends Declaration { kind: SyntaxKind.ImportClause; + parent?: ImportDeclaration; name?: Identifier; // Default binding namedBindings?: NamedImportBindings; } export interface NamespaceImport extends Declaration { kind: SyntaxKind.NamespaceImport; + parent?: ImportClause; name: Identifier; } @@ -1866,17 +1895,20 @@ export interface ExportDeclaration extends DeclarationStatement { kind: SyntaxKind.ExportDeclaration; + parent?: SourceFile | ModuleBlock; exportClause?: NamedExports; moduleSpecifier?: Expression; } export interface NamedImports extends Node { kind: SyntaxKind.NamedImports; + parent?: ImportClause; elements: NodeArray; } export interface NamedExports extends Node { kind: SyntaxKind.NamedExports; + parent?: ExportDeclaration; elements: NodeArray; } @@ -1884,12 +1916,14 @@ export interface ImportSpecifier extends Declaration { kind: SyntaxKind.ImportSpecifier; + parent?: NamedImports; propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) name: Identifier; // Declared name } export interface ExportSpecifier extends Declaration { kind: SyntaxKind.ExportSpecifier; + parent?: NamedExports; propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) name: Identifier; // Declared name } @@ -1898,6 +1932,7 @@ export interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; + parent?: SourceFile; isExportEquals?: boolean; expression: Expression; } From 6c9ba46e8b9253e95d899a9d6fbef2aba16ba4b9 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Sun, 19 Feb 2017 22:03:32 +0100 Subject: [PATCH 026/167] Fix compile errors --- src/compiler/checker.ts | 2 +- src/services/breakpoints.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 12b55aa818b..541b49acb9a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11546,7 +11546,7 @@ namespace ts { if (isBindingPattern(declaration.parent)) { const parentDeclaration = declaration.parent.parent; const name = declaration.propertyName || declaration.name; - if (isVariableLike(parentDeclaration) && + if (parentDeclaration.kind !== SyntaxKind.BindingElement && parentDeclaration.type && !isBindingPattern(name)) { const text = getTextOfPropertyName(name); diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index c751cf3871b..1f6bec41109 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -370,8 +370,8 @@ namespace ts.BreakpointResolver { } function textSpanFromVariableDeclaration(variableDeclaration: VariableDeclaration): TextSpan { - const declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] === variableDeclaration) { + if (variableDeclaration.parent.kind === SyntaxKind.VariableDeclarationList && + variableDeclaration.parent.declarations[0] === variableDeclaration) { // First declaration - include let keyword return textSpan(findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); } @@ -400,8 +400,8 @@ namespace ts.BreakpointResolver { return textSpanFromVariableDeclaration(variableDeclaration); } - const declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] !== variableDeclaration) { + if (variableDeclaration.parent.kind === SyntaxKind.VariableDeclarationList && + variableDeclaration.parent.declarations[0] !== variableDeclaration) { // If we cannot set breakpoint on this declaration, set it on previous one // Because the variable declaration may be binding pattern and // we would like to set breakpoint in last binding element if that's the case, From 0290e20b8e159ec6c1352cedf31d9448ebb7abae Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 21 Feb 2017 10:54:28 -0800 Subject: [PATCH 027/167] Get completion of JSX attributes type when tag name is a property access expression --- src/services/completions.ts | 21 +++++++---- tests/cases/fourslash/tsxCompletion14.ts | 44 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 tests/cases/fourslash/tsxCompletion14.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 1bf57d33fdc..91da6c7da14 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -898,8 +898,8 @@ namespace ts.Completions { return undefined; } - const { parent, kind } = contextToken; - if (kind === SyntaxKind.DotToken) { + let parent = contextToken.parent; + if (contextToken.kind === SyntaxKind.DotToken) { if (parent.kind === SyntaxKind.PropertyAccessExpression) { node = (contextToken.parent).expression; isRightOfDot = true; @@ -915,16 +915,24 @@ namespace ts.Completions { } } else if (sourceFile.languageVariant === LanguageVariant.JSX) { - switch (contextToken.parent.kind) { + // + // If the tagname is a property access expression, we will then walk up to the top most of property access expression. + // Then, try to get a JSX container and its associated attributes type. + if (parent && parent.kind === SyntaxKind.PropertyAccessExpression) { + contextToken = parent; + parent = parent.parent; + } + + switch (parent.kind) { case SyntaxKind.JsxClosingElement: - if (kind === SyntaxKind.SlashToken) { + if (contextToken.kind === SyntaxKind.SlashToken) { isStartingCloseTag = true; location = contextToken; } break; case SyntaxKind.BinaryExpression: - if (!((contextToken.parent as BinaryExpression).left.flags & NodeFlags.ThisNodeHasError)) { + if (!((parent as BinaryExpression).left.flags & NodeFlags.ThisNodeHasError)) { // It has a left-hand side, so we're not in an opening JSX tag. break; } @@ -933,7 +941,7 @@ namespace ts.Completions { case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxElement: case SyntaxKind.JsxOpeningElement: - if (kind === SyntaxKind.LessThanToken) { + if (contextToken.kind === SyntaxKind.LessThanToken) { isRightOfOpenTag = true; location = contextToken; } @@ -1401,6 +1409,7 @@ namespace ts.Completions { case SyntaxKind.LessThanSlashToken: case SyntaxKind.SlashToken: case SyntaxKind.Identifier: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.JsxAttributes: case SyntaxKind.JsxAttribute: case SyntaxKind.JsxSpreadAttribute: diff --git a/tests/cases/fourslash/tsxCompletion14.ts b/tests/cases/fourslash/tsxCompletion14.ts new file mode 100644 index 00000000000..32fbaef71f3 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion14.ts @@ -0,0 +1,44 @@ +/// +//@module: commonjs +//@jsx: preserve + +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props; } +//// } + +//@Filename: exporter.tsx +//// export class Thing { props: { ONE: string; TWO: number } } +//// export module M { +//// export declare function SFCComp(props: { Three: number; Four: string }): JSX.Element; +//// } + +//@Filename: file.tsx +//// import * as Exp from './exporter'; +//// var x1 = ; +//// var x2 = ; +//// var x3 = ; +//// var x4 = ; + + +goTo.marker("1"); +verify.completionListCount(2); +verify.completionListContains('ONE'); +verify.completionListContains('TWO'); + +goTo.marker("2"); +verify.completionListCount(2); +verify.completionListContains("Three"); +verify.completionListContains("Four"); + +goTo.marker("3"); +verify.completionListCount(2); +verify.completionListContains('ONE'); +verify.completionListContains('TWO'); + +goTo.marker("4"); +verify.completionListCount(2); +verify.completionListContains("Three"); +verify.completionListContains("Four"); From 7e2abfca28afa936bd3f4c367f8ebf110a441054 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 21 Feb 2017 18:44:57 -0800 Subject: [PATCH 028/167] Add a string indexer to any for object literals on a .js file --- src/compiler/checker.ts | 6 +- .../jsFileCompilationShortHandProperty.types | 4 +- .../reference/jsObjectsMarkedAsOpenEnded.js | 63 +++++++++ .../jsObjectsMarkedAsOpenEnded.symbols | 76 +++++++++++ .../jsObjectsMarkedAsOpenEnded.types | 128 ++++++++++++++++++ .../untypedModuleImport_allowJs.types | 8 +- .../salsa/jsObjectsMarkedAsOpenEnded.ts | 36 +++++ 7 files changed, 313 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/jsObjectsMarkedAsOpenEnded.js create mode 100644 tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols create mode 100644 tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types create mode 100644 tests/cases/conformance/salsa/jsObjectsMarkedAsOpenEnded.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 12b55aa818b..512e4be870b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -240,6 +240,7 @@ namespace ts { const silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); + const jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); const globals = createMap(); /** @@ -12144,6 +12145,7 @@ namespace ts { const contextualType = getApparentTypeOfContextualType(node); const contextualTypeHasPattern = contextualType && contextualType.pattern && (contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression); + const isJSObjectLiteral = !contextualType && isInJavaScriptFile(node); let typeFlags: TypeFlags = 0; let patternWithComputedProperties = false; let hasComputedStringProperty = false; @@ -12281,8 +12283,8 @@ namespace ts { return createObjectLiteralType(); function createObjectLiteralType() { - const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.String) : undefined; - const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.Number) : undefined; + const stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.String) : undefined; + const numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; result.flags |= TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); diff --git a/tests/baselines/reference/jsFileCompilationShortHandProperty.types b/tests/baselines/reference/jsFileCompilationShortHandProperty.types index d6badf44909..ab8892b4661 100644 --- a/tests/baselines/reference/jsFileCompilationShortHandProperty.types +++ b/tests/baselines/reference/jsFileCompilationShortHandProperty.types @@ -1,7 +1,7 @@ === tests/cases/compiler/a.js === function foo() { ->foo : () => { a: number; b: string; } +>foo : () => { [x: string]: any; a: number; b: string; } var a = 10; >a : number @@ -12,7 +12,7 @@ function foo() { >"Hello" : "Hello" return { ->{ a, b } : { a: number; b: string; } +>{ a, b } : { [x: string]: any; a: number; b: string; } a, >a : number diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.js b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.js new file mode 100644 index 00000000000..c9bec8b56af --- /dev/null +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.js @@ -0,0 +1,63 @@ +//// [tests/cases/conformance/salsa/jsObjectsMarkedAsOpenEnded.ts] //// + +//// [a.js] + +var variable = {}; +variable.a = 0; + +class C { + initializedMember = {}; + constructor() { + this.member = {}; + this.member.a = 0; + } +} + +var obj = { + property: {} +}; + +obj.property.a = 0; + +var arr = [{}]; + +function getObj() { + return {}; +} + + +//// [b.ts] +variable.a = 1; +(new C()).member.a = 1; +(new C()).initializedMember.a = 1; +obj.property.a = 1; +arr[0].a = 1; +getObj().a = 1; + + + +//// [output.js] +var variable = {}; +variable.a = 0; +var C = (function () { + function C() { + this.initializedMember = {}; + this.member = {}; + this.member.a = 0; + } + return C; +}()); +var obj = { + property: {} +}; +obj.property.a = 0; +var arr = [{}]; +function getObj() { + return {}; +} +variable.a = 1; +(new C()).member.a = 1; +(new C()).initializedMember.a = 1; +obj.property.a = 1; +arr[0].a = 1; +getObj().a = 1; diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols new file mode 100644 index 00000000000..35a39ac6a80 --- /dev/null +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.symbols @@ -0,0 +1,76 @@ +=== tests/cases/conformance/salsa/a.js === + +var variable = {}; +>variable : Symbol(variable, Decl(a.js, 1, 3)) + +variable.a = 0; +>variable : Symbol(variable, Decl(a.js, 1, 3)) + +class C { +>C : Symbol(C, Decl(a.js, 2, 15)) + + initializedMember = {}; +>initializedMember : Symbol(C.initializedMember, Decl(a.js, 4, 9)) + + constructor() { + this.member = {}; +>this.member : Symbol(C.member, Decl(a.js, 6, 19)) +>this : Symbol(C, Decl(a.js, 2, 15)) +>member : Symbol(C.member, Decl(a.js, 6, 19)) + + this.member.a = 0; +>this.member : Symbol(C.member, Decl(a.js, 6, 19)) +>this : Symbol(C, Decl(a.js, 2, 15)) +>member : Symbol(C.member, Decl(a.js, 6, 19)) + } +} + +var obj = { +>obj : Symbol(obj, Decl(a.js, 12, 3)) + + property: {} +>property : Symbol(property, Decl(a.js, 12, 11)) + +}; + +obj.property.a = 0; +>obj.property : Symbol(property, Decl(a.js, 12, 11)) +>obj : Symbol(obj, Decl(a.js, 12, 3)) +>property : Symbol(property, Decl(a.js, 12, 11)) + +var arr = [{}]; +>arr : Symbol(arr, Decl(a.js, 18, 3)) + +function getObj() { +>getObj : Symbol(getObj, Decl(a.js, 18, 15)) + + return {}; +} + + +=== tests/cases/conformance/salsa/b.ts === +variable.a = 1; +>variable : Symbol(variable, Decl(a.js, 1, 3)) + +(new C()).member.a = 1; +>(new C()).member : Symbol(C.member, Decl(a.js, 6, 19)) +>C : Symbol(C, Decl(a.js, 2, 15)) +>member : Symbol(C.member, Decl(a.js, 6, 19)) + +(new C()).initializedMember.a = 1; +>(new C()).initializedMember : Symbol(C.initializedMember, Decl(a.js, 4, 9)) +>C : Symbol(C, Decl(a.js, 2, 15)) +>initializedMember : Symbol(C.initializedMember, Decl(a.js, 4, 9)) + +obj.property.a = 1; +>obj.property : Symbol(property, Decl(a.js, 12, 11)) +>obj : Symbol(obj, Decl(a.js, 12, 3)) +>property : Symbol(property, Decl(a.js, 12, 11)) + +arr[0].a = 1; +>arr : Symbol(arr, Decl(a.js, 18, 3)) + +getObj().a = 1; +>getObj : Symbol(getObj, Decl(a.js, 18, 15)) + + diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types new file mode 100644 index 00000000000..97f61e68a5a --- /dev/null +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types @@ -0,0 +1,128 @@ +=== tests/cases/conformance/salsa/a.js === + +var variable = {}; +>variable : { [x: string]: any; } +>{} : { [x: string]: any; } + +variable.a = 0; +>variable.a = 0 : 0 +>variable.a : any +>variable : { [x: string]: any; } +>a : any +>0 : 0 + +class C { +>C : C + + initializedMember = {}; +>initializedMember : { [x: string]: any; } +>{} : { [x: string]: any; } + + constructor() { + this.member = {}; +>this.member = {} : { [x: string]: any; } +>this.member : { [x: string]: any; } +>this : this +>member : { [x: string]: any; } +>{} : { [x: string]: any; } + + this.member.a = 0; +>this.member.a = 0 : 0 +>this.member.a : any +>this.member : { [x: string]: any; } +>this : this +>member : { [x: string]: any; } +>a : any +>0 : 0 + } +} + +var obj = { +>obj : { [x: string]: any; property: { [x: string]: any; }; } +>{ property: {}} : { [x: string]: any; property: { [x: string]: any; }; } + + property: {} +>property : { [x: string]: any; } +>{} : { [x: string]: any; } + +}; + +obj.property.a = 0; +>obj.property.a = 0 : 0 +>obj.property.a : any +>obj.property : { [x: string]: any; } +>obj : { [x: string]: any; property: { [x: string]: any; }; } +>property : { [x: string]: any; } +>a : any +>0 : 0 + +var arr = [{}]; +>arr : { [x: string]: any; }[] +>[{}] : { [x: string]: any; }[] +>{} : { [x: string]: any; } + +function getObj() { +>getObj : () => { [x: string]: any; } + + return {}; +>{} : { [x: string]: any; } +} + + +=== tests/cases/conformance/salsa/b.ts === +variable.a = 1; +>variable.a = 1 : 1 +>variable.a : any +>variable : { [x: string]: any; } +>a : any +>1 : 1 + +(new C()).member.a = 1; +>(new C()).member.a = 1 : 1 +>(new C()).member.a : any +>(new C()).member : { [x: string]: any; } +>(new C()) : C +>new C() : C +>C : typeof C +>member : { [x: string]: any; } +>a : any +>1 : 1 + +(new C()).initializedMember.a = 1; +>(new C()).initializedMember.a = 1 : 1 +>(new C()).initializedMember.a : any +>(new C()).initializedMember : { [x: string]: any; } +>(new C()) : C +>new C() : C +>C : typeof C +>initializedMember : { [x: string]: any; } +>a : any +>1 : 1 + +obj.property.a = 1; +>obj.property.a = 1 : 1 +>obj.property.a : any +>obj.property : { [x: string]: any; } +>obj : { [x: string]: any; property: { [x: string]: any; }; } +>property : { [x: string]: any; } +>a : any +>1 : 1 + +arr[0].a = 1; +>arr[0].a = 1 : 1 +>arr[0].a : any +>arr[0] : { [x: string]: any; } +>arr : { [x: string]: any; }[] +>0 : 0 +>a : any +>1 : 1 + +getObj().a = 1; +>getObj().a = 1 : 1 +>getObj().a : any +>getObj() : { [x: string]: any; } +>getObj : () => { [x: string]: any; } +>a : any +>1 : 1 + + diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.types b/tests/baselines/reference/untypedModuleImport_allowJs.types index 5a34fdcb646..108ba60ccb3 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.types +++ b/tests/baselines/reference/untypedModuleImport_allowJs.types @@ -1,22 +1,22 @@ === /a.ts === import foo from "foo"; ->foo : { bar(): number; } +>foo : { [x: string]: any; bar(): number; } foo.bar(); >foo.bar() : number >foo.bar : () => number ->foo : { bar(): number; } +>foo : { [x: string]: any; bar(): number; } >bar : () => number === /node_modules/foo/index.js === // Same as untypedModuleImport.ts but with --allowJs, so the package will actually be typed. exports.default = { bar() { return 0; } } ->exports.default = { bar() { return 0; } } : { bar(): number; } +>exports.default = { bar() { return 0; } } : { [x: string]: any; bar(): number; } >exports.default : any >exports : any >default : any ->{ bar() { return 0; } } : { bar(): number; } +>{ bar() { return 0; } } : { [x: string]: any; bar(): number; } >bar : () => number >0 : 0 diff --git a/tests/cases/conformance/salsa/jsObjectsMarkedAsOpenEnded.ts b/tests/cases/conformance/salsa/jsObjectsMarkedAsOpenEnded.ts new file mode 100644 index 00000000000..52b27641f0d --- /dev/null +++ b/tests/cases/conformance/salsa/jsObjectsMarkedAsOpenEnded.ts @@ -0,0 +1,36 @@ +// @out: output.js +// @allowJs: true + +// @filename: a.js +var variable = {}; +variable.a = 0; + +class C { + initializedMember = {}; + constructor() { + this.member = {}; + this.member.a = 0; + } +} + +var obj = { + property: {} +}; + +obj.property.a = 0; + +var arr = [{}]; + +function getObj() { + return {}; +} + + +// @filename: b.ts +variable.a = 1; +(new C()).member.a = 1; +(new C()).initializedMember.a = 1; +obj.property.a = 1; +arr[0].a = 1; +getObj().a = 1; + From 1c25034a18d736e07a3f6ad9fb05c3450929e8d3 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 22 Feb 2017 16:15:16 -0800 Subject: [PATCH 029/167] instantiate generic this param correctly --- src/compiler/checker.ts | 1 + src/compiler/types.ts | 1 + ...sDoesntImplementInheritedAbstractMember.ts | 2 +- .../fixClassIncorrectlyImplementsInterface.ts | 4 +-- src/services/codefixes/helpers.ts | 14 ++------ .../codeFixClassExtendAbstractMethod.ts | 2 ++ .../codeFixClassExtendAbstractMethodThis.ts | 13 +++++++ ...entInterfaceMethodThisAndSelfReference.ts} | 4 +-- tests/cases/fourslash/quickInfoOnThis5.ts | 35 +++++++++++++++++++ 9 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts rename tests/cases/fourslash/{codeFixClassImplementInterfaceMethodWithParams.ts => codeFixClassImplementInterfaceMethodThisAndSelfReference.ts} (71%) create mode 100644 tests/cases/fourslash/quickInfoOnThis5.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 12b55aa818b..8b926832200 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -97,6 +97,7 @@ namespace ts { getBaseTypes, getBaseTypeOfLiteralType, getWidenedType, + getTypeWithThisArgument, getTypeFromTypeNode: node => { node = getParseTreeNode(node, isTypeNode); return node ? getTypeFromTypeNode(node) : unknownType; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index de42d5d9745..f4e432bc536 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2411,6 +2411,7 @@ getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; + getTypeWithThisArgument(type: Type, thisArgument?: Type): Type; getWidenedType(type: Type): Type; getReturnTypeOfSignature(signature: Signature): Type; /** diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index 22546e55ecc..f7e0fde8d43 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -23,7 +23,7 @@ namespace ts.codefix { const startPos = classDecl.members.pos; const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; - const instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + const instantiatedExtendsType = checker.getTypeWithThisArgument(checker.getBaseTypes(classType)[0], classType.thisType); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 42488dc2aed..aa7b320b13c 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -17,7 +17,7 @@ namespace ts.codefix { } const startPos: number = classDecl.members.pos; - const classType = checker.getTypeAtLocation(classDecl); + const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDecl); const hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, IndexKind.Number); @@ -25,7 +25,7 @@ namespace ts.codefix { const result: CodeAction[] = []; for (const implementedTypeNode of implementedTypeNodes) { - const implementedType = checker.getTypeFromTypeNode(implementedTypeNode) as InterfaceType; + const implementedType = checker.getTypeWithThisArgument(checker.getTypeFromTypeNode(implementedTypeNode), classType.thisType) as InterfaceType; // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. const implementedTypeSymbols = checker.getPropertiesOfType(implementedType); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 45479e49474..d20fc0129cd 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -32,22 +32,14 @@ namespace ts.codefix { const name = declaration.name ? declaration.name.getText() : undefined; const visibility = getVisibilityPrefixWithSpace(getModifierFlags(declaration)); - const typeAtNewDeclaration = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); switch (declaration.kind) { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: - let typeString: string | undefined = undefined; - const typeAtOldDeclaration = checker.getTypeAtLocation(declaration); - if ((typeAtOldDeclaration as TypeParameter).isThisType) { - typeString = "this"; - } - else { - typeString = checker.typeToString(typeAtNewDeclaration, enclosingDeclaration, TypeFormatFlags.None); - } - + const typeString = checker.typeToString(type, enclosingDeclaration, TypeFormatFlags.None); return `${visibility}${name}: ${typeString};${newlineChar}`; case SyntaxKind.MethodSignature: @@ -59,7 +51,7 @@ namespace ts.codefix { // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - const signatures = checker.getSignaturesOfType(typeAtNewDeclaration, SignatureKind.Call); + const signatures = checker.getSignaturesOfType(type, SignatureKind.Call); if (!(signatures && signatures.length > 0)) { return ""; } diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts index a657dfeb718..344a7ee3f2b 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts @@ -2,6 +2,7 @@ //// abstract class A { //// abstract f(a: number, b: string): boolean; +//// abstract f(a: number, b: string): this; //// abstract f(a: string, b: number): Function; //// abstract f(a: string): Function; //// } @@ -10,6 +11,7 @@ verify.rangeAfterCodeFix(` f(a: number, b: string): boolean; + f(a: number, b: string): this; f(a: string, b: number): Function; f(a: string): Function; f(a: any, b?: any) { diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts new file mode 100644 index 00000000000..55b3ad4b77e --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts @@ -0,0 +1,13 @@ +/// + +//// abstract class A { +//// abstract f(): this; +//// } +//// +//// class C extends A {[| |]} + +verify.rangeAfterCodeFix(` + f(): this { + throw new Error('Method not implemented.'); + } +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts similarity index 71% rename from tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts rename to tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts index 0ee842975e0..95cc3476bf1 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts @@ -1,14 +1,14 @@ /// //// interface I { -//// f(x: number, y: string): I +//// f(x: number, y: this): I //// } //// //// class C implements I {[| //// |]} verify.rangeAfterCodeFix(` -f(x: number,y: string): I { +f(x: number,y: this): I { throw new Error('Method not implemented.'); } `); diff --git a/tests/cases/fourslash/quickInfoOnThis5.ts b/tests/cases/fourslash/quickInfoOnThis5.ts new file mode 100644 index 00000000000..fd09aeb4a07 --- /dev/null +++ b/tests/cases/fourslash/quickInfoOnThis5.ts @@ -0,0 +1,35 @@ +/// + +verify.quickInfos({ + 1: "this: ContextualInterface", + 2: "(parameter) this: void" +}); + + + +////interface ContextualInterface { +//// m: number; +//// method(this: this, n: number); +////} +////let o: ContextualInterface = { +//// m: 12, +//// method(n) { +//// let x = this/*1*/.m; +//// } +////} +////interface ContextualInterface2 { +//// (this: void, n: number): void; +////} +////let contextualInterface2: ContextualInterface2 = function (th/*2*/is, n) { } + +class A { + x: number + myMethod(): this { return this; } +} + +class B extends A { + constructor(){ + super(); + this.myMethod(); + } +} From fbccb62d4b7a25994b3adfc87e80029f9d4b5ef9 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 22 Feb 2017 16:20:14 -0800 Subject: [PATCH 030/167] cleanup tests --- tests/cases/fourslash/quickInfoOnThis5.ts | 35 ----------------------- 1 file changed, 35 deletions(-) delete mode 100644 tests/cases/fourslash/quickInfoOnThis5.ts diff --git a/tests/cases/fourslash/quickInfoOnThis5.ts b/tests/cases/fourslash/quickInfoOnThis5.ts deleted file mode 100644 index fd09aeb4a07..00000000000 --- a/tests/cases/fourslash/quickInfoOnThis5.ts +++ /dev/null @@ -1,35 +0,0 @@ -/// - -verify.quickInfos({ - 1: "this: ContextualInterface", - 2: "(parameter) this: void" -}); - - - -////interface ContextualInterface { -//// m: number; -//// method(this: this, n: number); -////} -////let o: ContextualInterface = { -//// m: 12, -//// method(n) { -//// let x = this/*1*/.m; -//// } -////} -////interface ContextualInterface2 { -//// (this: void, n: number): void; -////} -////let contextualInterface2: ContextualInterface2 = function (th/*2*/is, n) { } - -class A { - x: number - myMethod(): this { return this; } -} - -class B extends A { - constructor(){ - super(); - this.myMethod(); - } -} From 168d367b5e740ae1896c01a26d6bb3d2af038566 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 22 Feb 2017 19:16:55 -0800 Subject: [PATCH 031/167] Contextually type 'this' in accessors of object literals --- src/compiler/checker.ts | 97 +++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9fb71884c51..69c294e97c2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8983,11 +8983,19 @@ namespace ts { return regularNew; } + function getWidenedProperty(prop: Symbol): Symbol { + const original = getTypeOfSymbol(prop); + const widened = getWidenedType(original); + return widened === original ? prop : createSymbolWithType(prop, widened); + } + function getWidenedTypeOfObjectLiteral(type: Type): Type { - const members = transformTypeOfMembers(type, prop => { - const widened = getWidenedType(prop); - return prop === widened ? prop : widened; - }); + const members = createMap(); + for (let prop of getPropertiesOfObjectType(type)) { + // Since get accessors already widen their return value there is no need to + // widen accessor based properties here. + members.set(prop.name, prop.flags & SymbolFlags.Property ? getWidenedProperty(prop) : prop); + }; const stringIndexInfo = getIndexInfoOfType(type, IndexKind.String); const numberIndexInfo = getIndexInfoOfType(type, IndexKind.Number); return createAnonymousType(type.symbol, members, emptyArray, emptyArray, @@ -11471,7 +11479,9 @@ namespace ts { } function getContainingObjectLiteral(func: FunctionLikeDeclaration) { - return func.kind === SyntaxKind.MethodDeclaration && func.parent.kind === SyntaxKind.ObjectLiteralExpression ? func.parent : + return (func.kind === SyntaxKind.MethodDeclaration || + func.kind === SyntaxKind.GetAccessor || + func.kind === SyntaxKind.SetAccessor) && func.parent.kind === SyntaxKind.ObjectLiteralExpression ? func.parent : func.kind === SyntaxKind.FunctionExpression && func.parent.kind === SyntaxKind.PropertyAssignment ? func.parent.parent : undefined; } @@ -11487,7 +11497,10 @@ namespace ts { } function getContextualThisParameterType(func: FunctionLikeDeclaration): Type { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) { + if (func.kind === SyntaxKind.ArrowFunction) { + return undefined; + } + if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { const contextualSignature = getContextualSignature(func); if (contextualSignature) { const thisParameter = contextualSignature.thisParameter; @@ -11495,36 +11508,36 @@ namespace ts { return getTypeOfSymbol(thisParameter); } } - const containingLiteral = getContainingObjectLiteral(func); - if (containingLiteral) { - // We have an object literal method. Check if the containing object literal has a contextual type - // and if that contextual type is or includes a ThisType. If so, T is the contextual type for - // 'this'. We continue looking in any directly enclosing object literals. - let objectLiteral = containingLiteral; - while (true) { - const type = getApparentTypeOfContextualType(objectLiteral); - if (type) { - const thisType = getThisTypeFromContextualType(type); - if (thisType) { - return thisType; - } + } + const containingLiteral = getContainingObjectLiteral(func); + if (containingLiteral) { + // We have an object literal method. Check if the containing object literal has a contextual type + // and if that contextual type is or includes a ThisType. If so, T is the contextual type for + // 'this'. We continue looking in any directly enclosing object literals. + let objectLiteral = containingLiteral; + while (true) { + const type = getApparentTypeOfContextualType(objectLiteral); + if (type) { + const thisType = getThisTypeFromContextualType(type); + if (thisType) { + return thisType; } - if (objectLiteral.parent.kind !== SyntaxKind.PropertyAssignment) { - break; - } - objectLiteral = objectLiteral.parent.parent; } - // There was no contextual ThisType for the containing object literal, so the contextual type - // for 'this' is the type of the object literal itself. - return checkExpressionCached(containingLiteral); + if (objectLiteral.parent.kind !== SyntaxKind.PropertyAssignment) { + break; + } + objectLiteral = objectLiteral.parent.parent; } - // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the - // contextual type for 'this' is 'obj'. - if (func.parent.kind === SyntaxKind.BinaryExpression && (func.parent).operatorToken.kind === SyntaxKind.EqualsToken) { - const target = (func.parent).left; - if (target.kind === SyntaxKind.PropertyAccessExpression || target.kind === SyntaxKind.ElementAccessExpression) { - return checkExpressionCached((target).expression); - } + // There was no contextual ThisType for the containing object literal, so the contextual type + // for 'this' is the type of the object literal itself. + return checkExpressionCached(containingLiteral); + } + // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the + // contextual type for 'this' is 'obj'. + if (func.parent.kind === SyntaxKind.BinaryExpression && (func.parent).operatorToken.kind === SyntaxKind.EqualsToken) { + const target = (func.parent).left; + if (target.kind === SyntaxKind.PropertyAccessExpression || target.kind === SyntaxKind.ElementAccessExpression) { + return checkExpressionCached((target).expression); } } return undefined; @@ -12287,7 +12300,7 @@ namespace ts { // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. Debug.assert(memberDecl.kind === SyntaxKind.GetAccessor || memberDecl.kind === SyntaxKind.SetAccessor); - checkAccessorDeclaration(memberDecl); + checkNodeDeferred(memberDecl); } if (hasDynamicName(memberDecl)) { @@ -16942,13 +16955,8 @@ namespace ts { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } - else { - checkNodeDeferred(node); - } + checkSourceElement(node.body); + registerForUnusedIdentifiersCheck(node); } function checkAccessorDeclarationTypesIdentical(first: AccessorDeclaration, second: AccessorDeclaration, getAnnotatedType: (a: AccessorDeclaration) => Type, message: DiagnosticMessage) { @@ -16959,11 +16967,6 @@ namespace ts { } } - function checkAccessorDeferred(node: AccessorDeclaration) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } - function checkMissingDeclaration(node: Node) { checkDecorators(node); } @@ -20630,7 +20633,7 @@ namespace ts { break; case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: - checkAccessorDeferred(node); + checkAccessorDeclaration(node); break; case SyntaxKind.ClassExpression: checkClassExpressionDeferred(node); From c2d8a593b9eb9642d7a2bc57d4cd49bdd85c206e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 22 Feb 2017 19:18:53 -0800 Subject: [PATCH 032/167] Accept new baselines --- .../commentsOnObjectLiteral3.symbols | 7 +++++ .../reference/commentsOnObjectLiteral3.types | 26 +++++++++---------- ...declFileObjectLiteralWithAccessors.symbols | 3 +++ .../declFileObjectLiteralWithAccessors.types | 6 ++--- ...eclFileObjectLiteralWithOnlySetter.symbols | 3 +++ .../declFileObjectLiteralWithOnlySetter.types | 6 ++--- ...iationAssignmentWithIndexingOnLHS3.symbols | 7 +++++ ...ntiationAssignmentWithIndexingOnLHS3.types | 12 ++++----- .../thisTypeInAccessorsNegative.errors.txt | 5 +--- 9 files changed, 46 insertions(+), 29 deletions(-) diff --git a/tests/baselines/reference/commentsOnObjectLiteral3.symbols b/tests/baselines/reference/commentsOnObjectLiteral3.symbols index 3d58fe2d6d7..34b4c706b42 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral3.symbols +++ b/tests/baselines/reference/commentsOnObjectLiteral3.symbols @@ -21,6 +21,10 @@ var v = { >a : Symbol(a, Decl(commentsOnObjectLiteral3.ts, 8, 13), Decl(commentsOnObjectLiteral3.ts, 12, 18)) return this.prop; +>this.prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) +>this : Symbol(v, Decl(commentsOnObjectLiteral3.ts, 1, 7)) +>prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) + } /*trailing 1*/, //setter set a(value) { @@ -28,6 +32,9 @@ var v = { >value : Symbol(value, Decl(commentsOnObjectLiteral3.ts, 14, 7)) this.prop = value; +>this.prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) +>this : Symbol(v, Decl(commentsOnObjectLiteral3.ts, 1, 7)) +>prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) >value : Symbol(value, Decl(commentsOnObjectLiteral3.ts, 14, 7)) } // trailing 2 diff --git a/tests/baselines/reference/commentsOnObjectLiteral3.types b/tests/baselines/reference/commentsOnObjectLiteral3.types index 4053e7e3f89..b869e961401 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral3.types +++ b/tests/baselines/reference/commentsOnObjectLiteral3.types @@ -1,8 +1,8 @@ === tests/cases/compiler/commentsOnObjectLiteral3.ts === var v = { ->v : { prop: number; func: () => void; func1(): void; a: any; } ->{ //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; } // trailing 2} : { prop: number; func: () => void; func1(): void; a: any; } +>v : { prop: number; func: () => void; func1(): void; a: number; } +>{ //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; } // trailing 2} : { prop: number; func: () => void; func1(): void; a: number; } //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, @@ -21,25 +21,25 @@ var v = { //getter get a() { ->a : any +>a : number return this.prop; ->this.prop : any ->this : any ->prop : any +>this.prop : number +>this : { prop: number; func: () => void; func1(): void; a: number; } +>prop : number } /*trailing 1*/, //setter set a(value) { ->a : any ->value : any +>a : number +>value : number this.prop = value; ->this.prop = value : any ->this.prop : any ->this : any ->prop : any ->value : any +>this.prop = value : number +>this.prop : number +>this : { prop: number; func: () => void; func1(): void; a: number; } +>prop : number +>value : number } // trailing 2 }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols b/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols index 862b0b3781e..df94b262c74 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols @@ -15,6 +15,9 @@ function /*1*/makePoint(x: number) { set x(a: number) { this.b = a; } >x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30)) >a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14)) +>this.b : Symbol(b, Decl(declFileObjectLiteralWithAccessors.ts, 2, 12)) +>this : Symbol(__object, Decl(declFileObjectLiteralWithAccessors.ts, 2, 10)) +>b : Symbol(b, Decl(declFileObjectLiteralWithAccessors.ts, 2, 12)) >a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14)) }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.types b/tests/baselines/reference/declFileObjectLiteralWithAccessors.types index 389b88de565..1c36f321118 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.types +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.types @@ -19,9 +19,9 @@ function /*1*/makePoint(x: number) { >x : number >a : number >this.b = a : number ->this.b : any ->this : any ->b : any +>this.b : number +>this : { b: number; x: number; } +>b : number >a : number }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols index f7474466140..9dd2461b871 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols @@ -11,6 +11,9 @@ function /*1*/makePoint(x: number) { set x(a: number) { this.b = a; } >x : Symbol(x, Decl(declFileObjectLiteralWithOnlySetter.ts, 3, 14)) >a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14)) +>this.b : Symbol(b, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 12)) +>this : Symbol(__object, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 10)) +>b : Symbol(b, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 12)) >a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14)) }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types index 2f15818e0f2..bf62561f57d 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types @@ -15,9 +15,9 @@ function /*1*/makePoint(x: number) { >x : number >a : number >this.b = a : number ->this.b : any ->this : any ->b : any +>this.b : number +>this : { b: number; x: number; } +>b : number >a : number }; diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols index dbd5aa150dc..785a5654681 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols @@ -8,11 +8,18 @@ var object = { get 0() { return this._0; +>this._0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) +>this : Symbol(object, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 12)) +>_0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) + }, set 0(x: number) { >x : Symbol(x, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 6, 10)) this._0 = x; +>this._0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) +>this : Symbol(object, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 12)) +>_0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) >x : Symbol(x, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 6, 10)) }, diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types index 32e5b33e411..77026be2795 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types @@ -10,9 +10,9 @@ var object = { get 0() { return this._0; ->this._0 : any ->this : any ->_0 : any +>this._0 : number +>this : { _0: number; 0: number; } +>_0 : number }, set 0(x: number) { @@ -20,9 +20,9 @@ var object = { this._0 = x; >this._0 = x : number ->this._0 : any ->this : any ->_0 : any +>this._0 : number +>this : { _0: number; 0: number; } +>_0 : number >x : number }, diff --git a/tests/baselines/reference/thisTypeInAccessorsNegative.errors.txt b/tests/baselines/reference/thisTypeInAccessorsNegative.errors.txt index 5396f1f4316..eb2c93e7845 100644 --- a/tests/baselines/reference/thisTypeInAccessorsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInAccessorsNegative.errors.txt @@ -1,9 +1,8 @@ tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts(10,9): error TS2682: 'get' and 'set' accessor must have the same 'this' type. tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts(11,9): error TS2682: 'get' and 'set' accessor must have the same 'this' type. -tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts(16,22): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -==== tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts (3 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts (2 errors) ==== interface Foo { n: number; x: number; @@ -24,7 +23,5 @@ tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts(16,22): er n: 16, // there is no contextual this type from an Foo.x. get x() { return this.n; } - ~~~~ -!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. } \ No newline at end of file From ec292c92e292c0747cda0002445caab76de9e627 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 22 Feb 2017 19:25:19 -0800 Subject: [PATCH 033/167] Update test --- .../baselines/reference/thisTypeInAccessorsNegative.errors.txt | 1 - tests/baselines/reference/thisTypeInAccessorsNegative.js | 2 -- .../conformance/types/thisType/thisTypeInAccessorsNegative.ts | 1 - 3 files changed, 4 deletions(-) diff --git a/tests/baselines/reference/thisTypeInAccessorsNegative.errors.txt b/tests/baselines/reference/thisTypeInAccessorsNegative.errors.txt index eb2c93e7845..cd609673723 100644 --- a/tests/baselines/reference/thisTypeInAccessorsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInAccessorsNegative.errors.txt @@ -21,7 +21,6 @@ tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts(11,9): err } const contextual: Foo = { n: 16, - // there is no contextual this type from an Foo.x. get x() { return this.n; } } \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeInAccessorsNegative.js b/tests/baselines/reference/thisTypeInAccessorsNegative.js index 4d0826232f4..92e18f163c3 100644 --- a/tests/baselines/reference/thisTypeInAccessorsNegative.js +++ b/tests/baselines/reference/thisTypeInAccessorsNegative.js @@ -13,7 +13,6 @@ const mismatch = { } const contextual: Foo = { n: 16, - // there is no contextual this type from an Foo.x. get x() { return this.n; } } @@ -26,6 +25,5 @@ var mismatch = { }; var contextual = { n: 16, - // there is no contextual this type from an Foo.x. get x() { return this.n; } }; diff --git a/tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts b/tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts index 69ff4175a92..67b7576a4b5 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInAccessorsNegative.ts @@ -15,6 +15,5 @@ const mismatch = { } const contextual: Foo = { n: 16, - // there is no contextual this type from an Foo.x. get x() { return this.n; } } From 9b6b6cc289a6afaeaba3ad6cb8310ad73ff62e80 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 22 Feb 2017 19:32:34 -0800 Subject: [PATCH 034/167] Fix linting error --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 69c294e97c2..8c1a91d203d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8991,7 +8991,7 @@ namespace ts { function getWidenedTypeOfObjectLiteral(type: Type): Type { const members = createMap(); - for (let prop of getPropertiesOfObjectType(type)) { + for (const prop of getPropertiesOfObjectType(type)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. members.set(prop.name, prop.flags & SymbolFlags.Property ? getWidenedProperty(prop) : prop); From 02ccd911590e7e0f67dbaa54e76d8cff72b2d56f Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 23 Feb 2017 15:20:08 -0800 Subject: [PATCH 035/167] Infer class properties from methods and not just constructors --- src/compiler/binder.ts | 42 ++-- src/compiler/checker.ts | 48 ++-- .../inferringClassMembersFromAssignments.js | 150 +++++++++++ ...ferringClassMembersFromAssignments.symbols | 198 +++++++++++++++ ...inferringClassMembersFromAssignments.types | 234 ++++++++++++++++++ .../inferringClassMembersFromAssignments.ts | 79 ++++++ 6 files changed, 718 insertions(+), 33 deletions(-) create mode 100644 tests/baselines/reference/inferringClassMembersFromAssignments.js create mode 100644 tests/baselines/reference/inferringClassMembersFromAssignments.symbols create mode 100644 tests/baselines/reference/inferringClassMembersFromAssignments.types create mode 100644 tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 51830c50bfe..2fc7317884d 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2238,23 +2238,31 @@ namespace ts { function bindThisPropertyAssignment(node: BinaryExpression) { Debug.assert(isInJavaScriptFile(node)); - // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionExpression) { - container.symbol.members = container.symbol.members || createMap(); - // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); - } - else if (container.kind === SyntaxKind.Constructor) { - // this.foo assignment in a JavaScript class - // Bind this property to the containing class - const saveContainer = container; - container = container.parent; - const symbol = bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.None); - if (symbol) { - // constructor-declared symbols can be overwritten by subsequent method declarations - (symbol as Symbol).isReplaceableByMethod = true; - } - container = saveContainer; + switch (container.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + // Declare a 'member' if the container is an ES5 class or ES6 constructor + container.symbol.members = container.symbol.members || createMap(); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); + break; + + case SyntaxKind.Constructor: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + // this.foo assignment in a JavaScript class + // Bind this property to the containing class + const containingClass = container.parent; + const symbol = hasModifier(container, ModifierFlags.Static) + ? declareSymbol(containingClass.symbol.exports, containingClass.symbol, node, SymbolFlags.Property, SymbolFlags.None) + : declareSymbol(containingClass.symbol.members, containingClass.symbol, node, SymbolFlags.Property, SymbolFlags.None); + + if (symbol) { + // symbols declared through 'this' property assignements can be overwritten by subsequent method declarations + (symbol as Symbol).isReplaceableByMethod = true; + } + break; } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 83fea11c993..93973fe71a8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3472,25 +3472,41 @@ namespace ts { return undefined; } - // Return the inferred type for a variable, parameter, or property declaration - function getTypeForJSSpecialPropertyDeclaration(declaration: Declaration): Type { - const expression = declaration.kind === SyntaxKind.BinaryExpression ? declaration : - declaration.kind === SyntaxKind.PropertyAccessExpression ? getAncestor(declaration, SyntaxKind.BinaryExpression) : - undefined; + function getWidendedTypeFromJSSpecialPropetyDeclarations(symbol: Symbol) { + const types: Type[] = []; + let definedInConstructor = false; + let definedInMethod = false; + for (const declaration of symbol.declarations) { + const expression = declaration.kind === SyntaxKind.BinaryExpression ? declaration : + declaration.kind === SyntaxKind.PropertyAccessExpression ? getAncestor(declaration, SyntaxKind.BinaryExpression) : + undefined; - if (!expression) { - return unknownType; - } - - if (expression.flags & NodeFlags.JavaScriptFile) { - // If there is a JSDoc type, use it - const type = getTypeForDeclarationFromJSDocComment(expression.parent); - if (type && type !== unknownType) { - return getWidenedType(type); + if (!expression) { + return unknownType; } + + if (isPropertyAccessExpression(expression.left) && expression.left.expression.kind === SyntaxKind.ThisKeyword) { + if (getThisContainer(expression, /*includeArrowFunctions*/ false).kind === SyntaxKind.Constructor) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + + if (expression.flags & NodeFlags.JavaScriptFile) { + // If there is a JSDoc type, use it + const type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + types.push(getWidenedType(type)); + continue; + } + } + + types.push(getWidenedLiteralType(checkExpressionCached(expression.right))); } - return getWidenedLiteralType(checkExpressionCached(expression.right)); + return getWidenedType(addOptionality(getUnionType(types, /*subtypeReduction*/ true), definedInMethod && !definedInConstructor)); } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if @@ -3647,7 +3663,7 @@ namespace ts { // * className.prototype.method = expr if (declaration.kind === SyntaxKind.BinaryExpression || declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { - type = getWidenedType(getUnionType(map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), /*subtypeReduction*/ true)); + type = getWidendedTypeFromJSSpecialPropetyDeclarations(symbol); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.js b/tests/baselines/reference/inferringClassMembersFromAssignments.js new file mode 100644 index 00000000000..6513a3b03a6 --- /dev/null +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.js @@ -0,0 +1,150 @@ +//// [tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts] //// + +//// [a.js] + +class C { + constructor() { + if (Math.random()) { + this.inConstructor = 0; + } + else { + this.inConstructor = "string" + } + } + method() { + if (Math.random()) { + this.inMethod = 0; + } + else { + this.inMethod = "string" + } + } + get() { + if (Math.random()) { + this.inGetter = 0; + } + else { + this.inGetter = "string" + } + } + set() { + if (Math.random()) { + this.inSetter = 0; + } + else { + this.inSetter = "string" + } + } + static method() { + if (Math.random()) { + this.inStaticMethod = 0; + } + else { + this.inStaticMethod = "string" + } + } + static get() { + if (Math.random()) { + this.inStaticGetter = 0; + } + else { + this.inStaticGetter = "string" + } + } + static set() { + if (Math.random()) { + this.inStaticSetter = 0; + } + else { + this.inStaticSetter = "string" + } + } +} + +//// [b.ts] +var c = new C(); + +var stringOrNumber: string | number; +var stringOrNumber = c.inConstructor; + +var stringOrNumberOrUndefined: string | number | undefined; + +var stringOrNumberOrUndefined = c.inMethod; +var stringOrNumberOrUndefined = c.inGetter; +var stringOrNumberOrUndefined = c.inSetter; + +var stringOrNumberOrUndefined = C.inStaticMethod; +var stringOrNumberOrUndefined = C.inStaticGetter; +var stringOrNumberOrUndefined = C.inStaticSetter; + + +//// [output.js] +var C = (function () { + function C() { + if (Math.random()) { + this.inConstructor = 0; + } + else { + this.inConstructor = "string"; + } + } + C.prototype.method = function () { + if (Math.random()) { + this.inMethod = 0; + } + else { + this.inMethod = "string"; + } + }; + C.prototype.get = function () { + if (Math.random()) { + this.inGetter = 0; + } + else { + this.inGetter = "string"; + } + }; + C.prototype.set = function () { + if (Math.random()) { + this.inSetter = 0; + } + else { + this.inSetter = "string"; + } + }; + C.method = function () { + if (Math.random()) { + this.inStaticMethod = 0; + } + else { + this.inStaticMethod = "string"; + } + }; + C.get = function () { + if (Math.random()) { + this.inStaticGetter = 0; + } + else { + this.inStaticGetter = "string"; + } + }; + C.set = function () { + if (Math.random()) { + this.inStaticSetter = 0; + } + else { + this.inStaticSetter = "string"; + } + }; + return C; +}()); +var c = new C(); +var stringOrNumber; +var stringOrNumber = c.inConstructor; +var stringOrNumberOrUndefined; +var stringOrNumberOrUndefined = c.inMethod; +var stringOrNumberOrUndefined = c.inGetter; +var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrUndefined = C.inStaticMethod; +var stringOrNumberOrUndefined = C.inStaticGetter; +var stringOrNumberOrUndefined = C.inStaticSetter; diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.symbols b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols new file mode 100644 index 00000000000..d96d4ff359f --- /dev/null +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols @@ -0,0 +1,198 @@ +=== tests/cases/conformance/salsa/a.js === + +class C { +>C : Symbol(C, Decl(a.js, 0, 0)) + + constructor() { + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inConstructor = 0; +>this.inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) + } + else { + this.inConstructor = "string" +>this.inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) + } + } + method() { +>method : Symbol(C.method, Decl(a.js, 9, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inMethod = 0; +>this.inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) + } + else { + this.inMethod = "string" +>this.inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) + } + } + get() { +>get : Symbol(C.get, Decl(a.js, 17, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inGetter = 0; +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) + } + else { + this.inGetter = "string" +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) + } + } + set() { +>set : Symbol(C.set, Decl(a.js, 25, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inSetter = 0; +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) + } + else { + this.inSetter = "string" +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) + } + } + static method() { +>method : Symbol(C.method, Decl(a.js, 33, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticMethod = 0; +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) + } + else { + this.inStaticMethod = "string" +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) + } + } + static get() { +>get : Symbol(C.get, Decl(a.js, 41, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticGetter = 0; +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) + } + else { + this.inStaticGetter = "string" +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) + } + } + static set() { +>set : Symbol(C.set, Decl(a.js, 49, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticSetter = 0; +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) + } + else { + this.inStaticSetter = "string" +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) + } + } +} + +=== tests/cases/conformance/salsa/b.ts === +var c = new C(); +>c : Symbol(c, Decl(b.ts, 0, 3)) +>C : Symbol(C, Decl(a.js, 0, 0)) + +var stringOrNumber: string | number; +>stringOrNumber : Symbol(stringOrNumber, Decl(b.ts, 2, 3), Decl(b.ts, 3, 3)) + +var stringOrNumber = c.inConstructor; +>stringOrNumber : Symbol(stringOrNumber, Decl(b.ts, 2, 3), Decl(b.ts, 3, 3)) +>c.inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) + +var stringOrNumberOrUndefined: string | number | undefined; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) + +var stringOrNumberOrUndefined = c.inMethod; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) +>c.inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) + +var stringOrNumberOrUndefined = c.inGetter; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) +>c.inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) + +var stringOrNumberOrUndefined = c.inSetter; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) +>c.inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) + +var stringOrNumberOrUndefined = C.inStaticMethod; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) +>C.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) + +var stringOrNumberOrUndefined = C.inStaticGetter; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) +>C.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) + +var stringOrNumberOrUndefined = C.inStaticSetter; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) +>C.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) + diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.types b/tests/baselines/reference/inferringClassMembersFromAssignments.types new file mode 100644 index 00000000000..c1b30ae4519 --- /dev/null +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.types @@ -0,0 +1,234 @@ +=== tests/cases/conformance/salsa/a.js === + +class C { +>C : C + + constructor() { + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inConstructor = 0; +>this.inConstructor = 0 : 0 +>this.inConstructor : string | number +>this : this +>inConstructor : string | number +>0 : 0 + } + else { + this.inConstructor = "string" +>this.inConstructor = "string" : "string" +>this.inConstructor : string | number +>this : this +>inConstructor : string | number +>"string" : "string" + } + } + method() { +>method : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inMethod = 0; +>this.inMethod = 0 : 0 +>this.inMethod : string | number | undefined +>this : this +>inMethod : string | number | undefined +>0 : 0 + } + else { + this.inMethod = "string" +>this.inMethod = "string" : "string" +>this.inMethod : string | number | undefined +>this : this +>inMethod : string | number | undefined +>"string" : "string" + } + } + get() { +>get : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inGetter = 0; +>this.inGetter = 0 : 0 +>this.inGetter : string | number | undefined +>this : this +>inGetter : string | number | undefined +>0 : 0 + } + else { + this.inGetter = "string" +>this.inGetter = "string" : "string" +>this.inGetter : string | number | undefined +>this : this +>inGetter : string | number | undefined +>"string" : "string" + } + } + set() { +>set : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inSetter = 0; +>this.inSetter = 0 : 0 +>this.inSetter : string | number | undefined +>this : this +>inSetter : string | number | undefined +>0 : 0 + } + else { + this.inSetter = "string" +>this.inSetter = "string" : "string" +>this.inSetter : string | number | undefined +>this : this +>inSetter : string | number | undefined +>"string" : "string" + } + } + static method() { +>method : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticMethod = 0; +>this.inStaticMethod = 0 : 0 +>this.inStaticMethod : string | number | undefined +>this : typeof C +>inStaticMethod : string | number | undefined +>0 : 0 + } + else { + this.inStaticMethod = "string" +>this.inStaticMethod = "string" : "string" +>this.inStaticMethod : string | number | undefined +>this : typeof C +>inStaticMethod : string | number | undefined +>"string" : "string" + } + } + static get() { +>get : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticGetter = 0; +>this.inStaticGetter = 0 : 0 +>this.inStaticGetter : string | number | undefined +>this : typeof C +>inStaticGetter : string | number | undefined +>0 : 0 + } + else { + this.inStaticGetter = "string" +>this.inStaticGetter = "string" : "string" +>this.inStaticGetter : string | number | undefined +>this : typeof C +>inStaticGetter : string | number | undefined +>"string" : "string" + } + } + static set() { +>set : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticSetter = 0; +>this.inStaticSetter = 0 : 0 +>this.inStaticSetter : string | number | undefined +>this : typeof C +>inStaticSetter : string | number | undefined +>0 : 0 + } + else { + this.inStaticSetter = "string" +>this.inStaticSetter = "string" : "string" +>this.inStaticSetter : string | number | undefined +>this : typeof C +>inStaticSetter : string | number | undefined +>"string" : "string" + } + } +} + +=== tests/cases/conformance/salsa/b.ts === +var c = new C(); +>c : C +>new C() : C +>C : typeof C + +var stringOrNumber: string | number; +>stringOrNumber : string | number + +var stringOrNumber = c.inConstructor; +>stringOrNumber : string | number +>c.inConstructor : string | number +>c : C +>inConstructor : string | number + +var stringOrNumberOrUndefined: string | number | undefined; +>stringOrNumberOrUndefined : string | number | undefined + +var stringOrNumberOrUndefined = c.inMethod; +>stringOrNumberOrUndefined : string | number | undefined +>c.inMethod : string | number | undefined +>c : C +>inMethod : string | number | undefined + +var stringOrNumberOrUndefined = c.inGetter; +>stringOrNumberOrUndefined : string | number | undefined +>c.inGetter : string | number | undefined +>c : C +>inGetter : string | number | undefined + +var stringOrNumberOrUndefined = c.inSetter; +>stringOrNumberOrUndefined : string | number | undefined +>c.inSetter : string | number | undefined +>c : C +>inSetter : string | number | undefined + +var stringOrNumberOrUndefined = C.inStaticMethod; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticMethod : string | number | undefined +>C : typeof C +>inStaticMethod : string | number | undefined + +var stringOrNumberOrUndefined = C.inStaticGetter; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticGetter : string | number | undefined +>C : typeof C +>inStaticGetter : string | number | undefined + +var stringOrNumberOrUndefined = C.inStaticSetter; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticSetter : string | number | undefined +>C : typeof C +>inStaticSetter : string | number | undefined + diff --git a/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts new file mode 100644 index 00000000000..dc63f09b3ab --- /dev/null +++ b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts @@ -0,0 +1,79 @@ +// @out: output.js +// @allowJs: true +// @strictNullChecks: true + +// @filename: a.js +class C { + constructor() { + if (Math.random()) { + this.inConstructor = 0; + } + else { + this.inConstructor = "string" + } + } + method() { + if (Math.random()) { + this.inMethod = 0; + } + else { + this.inMethod = "string" + } + } + get() { + if (Math.random()) { + this.inGetter = 0; + } + else { + this.inGetter = "string" + } + } + set() { + if (Math.random()) { + this.inSetter = 0; + } + else { + this.inSetter = "string" + } + } + static method() { + if (Math.random()) { + this.inStaticMethod = 0; + } + else { + this.inStaticMethod = "string" + } + } + static get() { + if (Math.random()) { + this.inStaticGetter = 0; + } + else { + this.inStaticGetter = "string" + } + } + static set() { + if (Math.random()) { + this.inStaticSetter = 0; + } + else { + this.inStaticSetter = "string" + } + } +} + +// @filename: b.ts +var c = new C(); + +var stringOrNumber: string | number; +var stringOrNumber = c.inConstructor; + +var stringOrNumberOrUndefined: string | number | undefined; + +var stringOrNumberOrUndefined = c.inMethod; +var stringOrNumberOrUndefined = c.inGetter; +var stringOrNumberOrUndefined = c.inSetter; + +var stringOrNumberOrUndefined = C.inStaticMethod; +var stringOrNumberOrUndefined = C.inStaticGetter; +var stringOrNumberOrUndefined = C.inStaticSetter; From fd8040978b0d3ab688488876e1d169bf32681420 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 23 Feb 2017 21:25:30 -0800 Subject: [PATCH 036/167] Allow primitive types in JSDoc to start wtih uppercase letters --- src/compiler/checker.ts | 52 +++++-- src/compiler/types.ts | 7 +- tests/baselines/reference/jsDocTypes.js | 137 ++++++++++++++++++ tests/baselines/reference/jsDocTypes.symbols | 133 +++++++++++++++++ tests/baselines/reference/jsDocTypes.types | 136 +++++++++++++++++ ...ileCompilationRestParamJsDocFunction.types | 16 +- tests/cases/conformance/salsa/jsDocTypes.ts | 80 ++++++++++ 7 files changed, 538 insertions(+), 23 deletions(-) create mode 100644 tests/baselines/reference/jsDocTypes.js create mode 100644 tests/baselines/reference/jsDocTypes.symbols create mode 100644 tests/baselines/reference/jsDocTypes.types create mode 100644 tests/cases/conformance/salsa/jsDocTypes.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 83fea11c993..ac5012a3bf9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5897,15 +5897,52 @@ namespace ts { return getTypeFromNonGenericTypeReference(node, symbol); } + function getPrimitiveTypeFromJSDocTypeReference(node: JSDocTypeReference): Type { + if (isIdentifier(node.name)) { + switch (node.name.text) { + case "String": + return stringType; + case "Number": + return numberType; + case "Boolean": + return booleanType; + case "Void": + return voidType; + case "Undefined": + return undefinedType; + case "Null": + return nullType; + case "Object": + return anyType; + case "Function": + return anyFunctionType; + case "Array": + case "array": + return !node.typeArguments || !node.typeArguments.length ? createArrayType(anyType) : undefined; + case "Promise": + case "promise": + return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined; + } + } + } + + function getTypeFromJSDocNullableTypeNode(node: JSDocNullableType) { + const type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getUnionType([type, nullType]) : type; + } + function getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): Type { const links = getNodeLinks(node); if (!links.resolvedType) { let symbol: Symbol; let type: Type; if (node.kind === SyntaxKind.JSDocTypeReference) { - const typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(typeReferenceName); - type = getTypeReferenceType(node, symbol); + type = getPrimitiveTypeFromJSDocTypeReference(node); + if (!type) { + const typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(typeReferenceName); + type = getTypeReferenceType(node, symbol); + } } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. @@ -6812,12 +6849,6 @@ namespace ts { return neverType; case SyntaxKind.ObjectKeyword: return nonPrimitiveType; - case SyntaxKind.JSDocNullKeyword: - return nullType; - case SyntaxKind.JSDocUndefinedKeyword: - return undefinedType; - case SyntaxKind.JSDocNeverKeyword: - return neverType; case SyntaxKind.ThisType: case SyntaxKind.ThisKeyword: return getTypeFromThisTypeNode(node); @@ -6844,8 +6875,9 @@ namespace ts { return getTypeFromUnionTypeNode(node); case SyntaxKind.IntersectionType: return getTypeFromIntersectionTypeNode(node); - case SyntaxKind.ParenthesizedType: case SyntaxKind.JSDocNullableType: + return getTypeFromJSDocNullableTypeNode(node); + case SyntaxKind.ParenthesizedType: case SyntaxKind.JSDocNonNullableType: case SyntaxKind.JSDocConstructorType: case SyntaxKind.JSDocThisType: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index de42d5d9745..df851eb07df 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -381,9 +381,6 @@ JSDocPropertyTag, JSDocTypeLiteral, JSDocLiteralType, - JSDocNullKeyword, - JSDocUndefinedKeyword, - JSDocNeverKeyword, // Synthesized list SyntaxList, @@ -423,9 +420,9 @@ LastBinaryOperator = CaretEqualsToken, FirstNode = QualifiedName, FirstJSDocNode = JSDocTypeExpression, - LastJSDocNode = JSDocNeverKeyword, + LastJSDocNode = JSDocLiteralType, FirstJSDocTagNode = JSDocComment, - LastJSDocTagNode = JSDocNeverKeyword + LastJSDocTagNode = JSDocLiteralType } export const enum NodeFlags { diff --git a/tests/baselines/reference/jsDocTypes.js b/tests/baselines/reference/jsDocTypes.js new file mode 100644 index 00000000000..a6df2f361c6 --- /dev/null +++ b/tests/baselines/reference/jsDocTypes.js @@ -0,0 +1,137 @@ +//// [tests/cases/conformance/salsa/jsDocTypes.ts] //// + +//// [a.js] + +/** @type {String} */ +var S; + +/** @type {string} */ +var s; + +/** @type {Number} */ +var N; + +/** @type {number} */ +var n; + +/** @type {Boolean} */ +var B; + +/** @type {boolean} */ +var b; + +/** @type {Void} */ +var V; + +/** @type {void} */ +var v; + +/** @type {Undefined} */ +var U; + +/** @type {undefined} */ +var u; + +/** @type {Null} */ +var Nl; + +/** @type {null} */ +var nl; + +/** @type {Array} */ +var A; + +/** @type {array} */ +var a; + +/** @type {Promise} */ +var P; + +/** @type {promise} */ +var p; + +/** @type {?number} */ +var nullable; + +/** @type {Object} */ +var Obj; + + + +//// [b.ts] +var S: string; +var s: string; +var N: number; +var n: number +var B: boolean; +var b: boolean; +var V :void; +var v: void; +var U: undefined; +var u: undefined; +var Nl: null; +var nl: null; +var A: any[]; +var a: any[]; +var P: Promise; +var p: Promise; +var nullable: number | null; +var Obj: any; + + +//// [a.js] +/** @type {String} */ +var S; +/** @type {string} */ +var s; +/** @type {Number} */ +var N; +/** @type {number} */ +var n; +/** @type {Boolean} */ +var B; +/** @type {boolean} */ +var b; +/** @type {Void} */ +var V; +/** @type {void} */ +var v; +/** @type {Undefined} */ +var U; +/** @type {undefined} */ +var u; +/** @type {Null} */ +var Nl; +/** @type {null} */ +var nl; +/** @type {Array} */ +var A; +/** @type {array} */ +var a; +/** @type {Promise} */ +var P; +/** @type {promise} */ +var p; +/** @type {?number} */ +var nullable; +/** @type {Object} */ +var Obj; +//// [b.js] +var S; +var s; +var N; +var n; +var B; +var b; +var V; +var v; +var U; +var u; +var Nl; +var nl; +var A; +var a; +var P; +var p; +var nullable; +var Obj; diff --git a/tests/baselines/reference/jsDocTypes.symbols b/tests/baselines/reference/jsDocTypes.symbols new file mode 100644 index 00000000000..9bde032cb44 --- /dev/null +++ b/tests/baselines/reference/jsDocTypes.symbols @@ -0,0 +1,133 @@ +=== tests/cases/conformance/salsa/a.js === + +/** @type {String} */ +var S; +>S : Symbol(S, Decl(a.js, 2, 3), Decl(b.ts, 0, 3)) + +/** @type {string} */ +var s; +>s : Symbol(s, Decl(a.js, 5, 3), Decl(b.ts, 1, 3)) + +/** @type {Number} */ +var N; +>N : Symbol(N, Decl(a.js, 8, 3), Decl(b.ts, 2, 3)) + +/** @type {number} */ +var n; +>n : Symbol(n, Decl(a.js, 11, 3), Decl(b.ts, 3, 3)) + +/** @type {Boolean} */ +var B; +>B : Symbol(B, Decl(a.js, 14, 3), Decl(b.ts, 4, 3)) + +/** @type {boolean} */ +var b; +>b : Symbol(b, Decl(a.js, 17, 3), Decl(b.ts, 5, 3)) + +/** @type {Void} */ +var V; +>V : Symbol(V, Decl(a.js, 20, 3), Decl(b.ts, 6, 3)) + +/** @type {void} */ +var v; +>v : Symbol(v, Decl(a.js, 23, 3), Decl(b.ts, 7, 3)) + +/** @type {Undefined} */ +var U; +>U : Symbol(U, Decl(a.js, 26, 3), Decl(b.ts, 8, 3)) + +/** @type {undefined} */ +var u; +>u : Symbol(u, Decl(a.js, 29, 3), Decl(b.ts, 9, 3)) + +/** @type {Null} */ +var Nl; +>Nl : Symbol(Nl, Decl(a.js, 32, 3), Decl(b.ts, 10, 3)) + +/** @type {null} */ +var nl; +>nl : Symbol(nl, Decl(a.js, 35, 3), Decl(b.ts, 11, 3)) + +/** @type {Array} */ +var A; +>A : Symbol(A, Decl(a.js, 38, 3), Decl(b.ts, 12, 3)) + +/** @type {array} */ +var a; +>a : Symbol(a, Decl(a.js, 41, 3), Decl(b.ts, 13, 3)) + +/** @type {Promise} */ +var P; +>P : Symbol(P, Decl(a.js, 44, 3), Decl(b.ts, 14, 3)) + +/** @type {promise} */ +var p; +>p : Symbol(p, Decl(a.js, 47, 3), Decl(b.ts, 15, 3)) + +/** @type {?number} */ +var nullable; +>nullable : Symbol(nullable, Decl(a.js, 50, 3), Decl(b.ts, 16, 3)) + +/** @type {Object} */ +var Obj; +>Obj : Symbol(Obj, Decl(a.js, 53, 3), Decl(b.ts, 17, 3)) + + + +=== tests/cases/conformance/salsa/b.ts === +var S: string; +>S : Symbol(S, Decl(a.js, 2, 3), Decl(b.ts, 0, 3)) + +var s: string; +>s : Symbol(s, Decl(a.js, 5, 3), Decl(b.ts, 1, 3)) + +var N: number; +>N : Symbol(N, Decl(a.js, 8, 3), Decl(b.ts, 2, 3)) + +var n: number +>n : Symbol(n, Decl(a.js, 11, 3), Decl(b.ts, 3, 3)) + +var B: boolean; +>B : Symbol(B, Decl(a.js, 14, 3), Decl(b.ts, 4, 3)) + +var b: boolean; +>b : Symbol(b, Decl(a.js, 17, 3), Decl(b.ts, 5, 3)) + +var V :void; +>V : Symbol(V, Decl(a.js, 20, 3), Decl(b.ts, 6, 3)) + +var v: void; +>v : Symbol(v, Decl(a.js, 23, 3), Decl(b.ts, 7, 3)) + +var U: undefined; +>U : Symbol(U, Decl(a.js, 26, 3), Decl(b.ts, 8, 3)) + +var u: undefined; +>u : Symbol(u, Decl(a.js, 29, 3), Decl(b.ts, 9, 3)) + +var Nl: null; +>Nl : Symbol(Nl, Decl(a.js, 32, 3), Decl(b.ts, 10, 3)) + +var nl: null; +>nl : Symbol(nl, Decl(a.js, 35, 3), Decl(b.ts, 11, 3)) + +var A: any[]; +>A : Symbol(A, Decl(a.js, 38, 3), Decl(b.ts, 12, 3)) + +var a: any[]; +>a : Symbol(a, Decl(a.js, 41, 3), Decl(b.ts, 13, 3)) + +var P: Promise; +>P : Symbol(P, Decl(a.js, 44, 3), Decl(b.ts, 14, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --)) + +var p: Promise; +>p : Symbol(p, Decl(a.js, 47, 3), Decl(b.ts, 15, 3)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --)) + +var nullable: number | null; +>nullable : Symbol(nullable, Decl(a.js, 50, 3), Decl(b.ts, 16, 3)) + +var Obj: any; +>Obj : Symbol(Obj, Decl(a.js, 53, 3), Decl(b.ts, 17, 3)) + diff --git a/tests/baselines/reference/jsDocTypes.types b/tests/baselines/reference/jsDocTypes.types new file mode 100644 index 00000000000..c0214edf627 --- /dev/null +++ b/tests/baselines/reference/jsDocTypes.types @@ -0,0 +1,136 @@ +=== tests/cases/conformance/salsa/a.js === + +/** @type {String} */ +var S; +>S : string + +/** @type {string} */ +var s; +>s : string + +/** @type {Number} */ +var N; +>N : number + +/** @type {number} */ +var n; +>n : number + +/** @type {Boolean} */ +var B; +>B : boolean + +/** @type {boolean} */ +var b; +>b : boolean + +/** @type {Void} */ +var V; +>V : void + +/** @type {void} */ +var v; +>v : void + +/** @type {Undefined} */ +var U; +>U : undefined + +/** @type {undefined} */ +var u; +>u : undefined + +/** @type {Null} */ +var Nl; +>Nl : null + +/** @type {null} */ +var nl; +>nl : null + +/** @type {Array} */ +var A; +>A : any[] + +/** @type {array} */ +var a; +>a : any[] + +/** @type {Promise} */ +var P; +>P : Promise + +/** @type {promise} */ +var p; +>p : Promise + +/** @type {?number} */ +var nullable; +>nullable : number | null + +/** @type {Object} */ +var Obj; +>Obj : any + + + +=== tests/cases/conformance/salsa/b.ts === +var S: string; +>S : string + +var s: string; +>s : string + +var N: number; +>N : number + +var n: number +>n : number + +var B: boolean; +>B : boolean + +var b: boolean; +>b : boolean + +var V :void; +>V : void + +var v: void; +>v : void + +var U: undefined; +>U : undefined + +var u: undefined; +>u : undefined + +var Nl: null; +>Nl : null +>null : null + +var nl: null; +>nl : null +>null : null + +var A: any[]; +>A : any[] + +var a: any[]; +>a : any[] + +var P: Promise; +>P : Promise +>Promise : Promise + +var p: Promise; +>p : Promise +>Promise : Promise + +var nullable: number | null; +>nullable : number | null +>null : null + +var Obj: any; +>Obj : any + diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types index c420454b8cf..f40e9164c38 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types @@ -11,8 +11,8 @@ * @returns {*} Returns the result of `func`. */ function apply(func, thisArg, args) { ->apply : (func: Function, thisArg: any, ...args: any[]) => any ->func : Function +>apply : (func: {}, thisArg: any, ...args: any[]) => any +>func : {} >thisArg : any >args : any[] @@ -29,7 +29,7 @@ function apply(func, thisArg, args) { >0 : 0 >func.call(thisArg) : any >func.call : (this: Function, thisArg: any, ...argArray: any[]) => any ->func : Function +>func : {} >call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any @@ -37,7 +37,7 @@ function apply(func, thisArg, args) { >1 : 1 >func.call(thisArg, args[0]) : any >func.call : (this: Function, thisArg: any, ...argArray: any[]) => any ->func : Function +>func : {} >call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any @@ -48,7 +48,7 @@ function apply(func, thisArg, args) { >2 : 2 >func.call(thisArg, args[0], args[1]) : any >func.call : (this: Function, thisArg: any, ...argArray: any[]) => any ->func : Function +>func : {} >call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any @@ -62,7 +62,7 @@ function apply(func, thisArg, args) { >3 : 3 >func.call(thisArg, args[0], args[1], args[2]) : any >func.call : (this: Function, thisArg: any, ...argArray: any[]) => any ->func : Function +>func : {} >call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any @@ -78,12 +78,12 @@ function apply(func, thisArg, args) { return func.apply(thisArg, args); >func.apply(thisArg, args) : any >func.apply : (this: Function, thisArg: any, argArray?: any) => any ->func : Function +>func : {} >apply : (this: Function, thisArg: any, argArray?: any) => any >thisArg : any >args : any[] } export default apply; ->apply : (func: Function, thisArg: any, ...args: any[]) => any +>apply : (func: {}, thisArg: any, ...args: any[]) => any diff --git a/tests/cases/conformance/salsa/jsDocTypes.ts b/tests/cases/conformance/salsa/jsDocTypes.ts new file mode 100644 index 00000000000..9a13c533d0a --- /dev/null +++ b/tests/cases/conformance/salsa/jsDocTypes.ts @@ -0,0 +1,80 @@ +// @allowJS: true +// @suppressOutputPathCheck: true +// @strictNullChecks: true + +// @filename: a.js +/** @type {String} */ +var S; + +/** @type {string} */ +var s; + +/** @type {Number} */ +var N; + +/** @type {number} */ +var n; + +/** @type {Boolean} */ +var B; + +/** @type {boolean} */ +var b; + +/** @type {Void} */ +var V; + +/** @type {void} */ +var v; + +/** @type {Undefined} */ +var U; + +/** @type {undefined} */ +var u; + +/** @type {Null} */ +var Nl; + +/** @type {null} */ +var nl; + +/** @type {Array} */ +var A; + +/** @type {array} */ +var a; + +/** @type {Promise} */ +var P; + +/** @type {promise} */ +var p; + +/** @type {?number} */ +var nullable; + +/** @type {Object} */ +var Obj; + + + +// @filename: b.ts +var S: string; +var s: string; +var N: number; +var n: number +var B: boolean; +var b: boolean; +var V :void; +var v: void; +var U: undefined; +var u: undefined; +var Nl: null; +var nl: null; +var A: any[]; +var a: any[]; +var P: Promise; +var p: Promise; +var nullable: number | null; +var Obj: any; From 82b5655e66e3cc84dc95f96c80176ce7fc71548d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 24 Feb 2017 14:22:55 -0800 Subject: [PATCH 037/167] Special prop assignment symbol applies only to lhs In a Javascript file, the binder assigns a SpecialPropertyAssignment marker to the BinaryExpression node of several kinds of special assignments. Then it binds a special symbol whose declaration is that BinaryExpression node. But the symbol only applies to the left-hand side of the assignment. The right-hand side is an independent expression that should have its own symbols. Previously, symbol lookup in the checker didn't check whether a Javascript node that was part of a special property assignment came from the lhs or the rhs. So the right-hand side would also incorrectly get the special symbol intended for the left-hand side. `getSpecialPropertyAssignmentSymbolFromEntityName` in the checker now checks that its argument is the left-hand side of an assignment before returning a special property assignment symbol. --- src/compiler/checker.ts | 4 +++- .../cases/fourslash/renameJsObjectLiteralMethod.ts | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/renameJsObjectLiteralMethod.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 83fea11c993..b3c2726ba85 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20898,7 +20898,9 @@ namespace ts { return getSymbolOfNode(entityName.parent); } - if (isInJavaScriptFile(entityName) && entityName.parent.kind === SyntaxKind.PropertyAccessExpression) { + if (isInJavaScriptFile(entityName) && + entityName.parent.kind === SyntaxKind.PropertyAccessExpression && + entityName.parent === (entityName.parent.parent as BinaryExpression).left) { // Check if this is a special property assignment const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { diff --git a/tests/cases/fourslash/renameJsObjectLiteralMethod.ts b/tests/cases/fourslash/renameJsObjectLiteralMethod.ts new file mode 100644 index 00000000000..b4b9fb80528 --- /dev/null +++ b/tests/cases/fourslash/renameJsObjectLiteralMethod.ts @@ -0,0 +1,13 @@ +/// +// @allowJs: true +// @Filename: a.js +////const foo = { +//// set: function (x) { +//// this._x = x; +//// }, +//// copy: function ([|x|]) { +//// this._x = /**/[|x|].prop; +//// } +////}; +goTo.marker(); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); From 44e1140cf69605bc2c3a60c186b98b0e73a94423 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 24 Feb 2017 14:53:35 -0800 Subject: [PATCH 038/167] Rename tests --- ...alMethod.ts => renameJsSpecialAssignmentRhs1.ts} | 0 .../fourslash/renameJsSpecialAssignmentRhs2.ts | 13 +++++++++++++ 2 files changed, 13 insertions(+) rename tests/cases/fourslash/{renameJsObjectLiteralMethod.ts => renameJsSpecialAssignmentRhs1.ts} (100%) create mode 100644 tests/cases/fourslash/renameJsSpecialAssignmentRhs2.ts diff --git a/tests/cases/fourslash/renameJsObjectLiteralMethod.ts b/tests/cases/fourslash/renameJsSpecialAssignmentRhs1.ts similarity index 100% rename from tests/cases/fourslash/renameJsObjectLiteralMethod.ts rename to tests/cases/fourslash/renameJsSpecialAssignmentRhs1.ts diff --git a/tests/cases/fourslash/renameJsSpecialAssignmentRhs2.ts b/tests/cases/fourslash/renameJsSpecialAssignmentRhs2.ts new file mode 100644 index 00000000000..5b4b6e851cf --- /dev/null +++ b/tests/cases/fourslash/renameJsSpecialAssignmentRhs2.ts @@ -0,0 +1,13 @@ +/// +// @allowJs: true +// @Filename: a.js +////const foo = { +//// set: function (x) { +//// this._x = x; +//// }, +//// copy: function (/**/[|x|]) { +//// this._x = [|x|].prop; +//// } +////}; +goTo.marker(); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); From 9dc2bae2e657dd4c4553b9c0f3e7bb91f9dc10bf Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 24 Feb 2017 18:00:27 -0800 Subject: [PATCH 039/167] Use contextual type of object literal as 'this' in methods --- src/compiler/checker.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c1a91d203d..0218f21a27f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11512,25 +11512,26 @@ namespace ts { const containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { // We have an object literal method. Check if the containing object literal has a contextual type - // and if that contextual type is or includes a ThisType. If so, T is the contextual type for - // 'this'. We continue looking in any directly enclosing object literals. - let objectLiteral = containingLiteral; - while (true) { - const type = getApparentTypeOfContextualType(objectLiteral); - if (type) { - const thisType = getThisTypeFromContextualType(type); - if (thisType) { - return thisType; - } + // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in + // any directly enclosing object literals. + const contextualType = getApparentTypeOfContextualType(containingLiteral); + let literal = containingLiteral; + let type = contextualType; + while (type) { + const thisType = getThisTypeFromContextualType(type); + if (thisType) { + return thisType; } - if (objectLiteral.parent.kind !== SyntaxKind.PropertyAssignment) { + if (literal.parent.kind !== SyntaxKind.PropertyAssignment) { break; } - objectLiteral = objectLiteral.parent.parent; + literal = literal.parent.parent; + type = getApparentTypeOfContextualType(literal); } // There was no contextual ThisType for the containing object literal, so the contextual type - // for 'this' is the type of the object literal itself. - return checkExpressionCached(containingLiteral); + // for 'this' is the contextual type for the containing object literal or the type of the object + // literal itself. + return contextualType || checkExpressionCached(containingLiteral); } // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. From 16f403058fccec462c83ec7b7f9640e5f233ffd2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 24 Feb 2017 18:12:09 -0800 Subject: [PATCH 040/167] Accept new baselines --- tests/baselines/reference/castTest.symbols | 12 +-- tests/baselines/reference/castTest.types | 4 +- .../commentsOnObjectLiteral2.errors.txt | 5 +- .../reference/fixSignatureCaching.errors.txt | 98 +------------------ .../baselines/reference/objectSpread.symbols | 6 +- tests/baselines/reference/objectSpread.types | 2 +- .../reference/thisTypeInFunctions2.symbols | 18 ++-- .../reference/thisTypeInFunctions2.types | 18 ++-- 8 files changed, 30 insertions(+), 133 deletions(-) diff --git a/tests/baselines/reference/castTest.symbols b/tests/baselines/reference/castTest.symbols index 706f75a1028..0baee00ec47 100644 --- a/tests/baselines/reference/castTest.symbols +++ b/tests/baselines/reference/castTest.symbols @@ -71,13 +71,13 @@ var p_cast = ({ return new Point(this.x + dx, this.y + dy); >Point : Symbol(Point, Decl(castTest.ts, 11, 37)) ->this.x : Symbol(x, Decl(castTest.ts, 22, 23)) ->this : Symbol(__object, Decl(castTest.ts, 22, 22)) ->x : Symbol(x, Decl(castTest.ts, 22, 23)) +>this.x : Symbol(Point.x, Decl(castTest.ts, 14, 1)) +>this : Symbol(Point, Decl(castTest.ts, 11, 37)) +>x : Symbol(Point.x, Decl(castTest.ts, 14, 1)) >dx : Symbol(dx, Decl(castTest.ts, 25, 18)) ->this.y : Symbol(y, Decl(castTest.ts, 23, 9)) ->this : Symbol(__object, Decl(castTest.ts, 22, 22)) ->y : Symbol(y, Decl(castTest.ts, 23, 9)) +>this.y : Symbol(Point.y, Decl(castTest.ts, 15, 14)) +>this : Symbol(Point, Decl(castTest.ts, 11, 37)) +>y : Symbol(Point.y, Decl(castTest.ts, 15, 14)) >dy : Symbol(dy, Decl(castTest.ts, 25, 21)) }, diff --git a/tests/baselines/reference/castTest.types b/tests/baselines/reference/castTest.types index acdc58d0b25..08c9853dca6 100644 --- a/tests/baselines/reference/castTest.types +++ b/tests/baselines/reference/castTest.types @@ -93,12 +93,12 @@ var p_cast = ({ >Point : typeof Point >this.x + dx : number >this.x : number ->this : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; } +>this : Point >x : number >dx : number >this.y + dy : number >this.y : number ->this : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; } +>this : Point >y : number >dy : number diff --git a/tests/baselines/reference/commentsOnObjectLiteral2.errors.txt b/tests/baselines/reference/commentsOnObjectLiteral2.errors.txt index 3748d0387b6..2a2394ced48 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral2.errors.txt +++ b/tests/baselines/reference/commentsOnObjectLiteral2.errors.txt @@ -1,8 +1,7 @@ tests/cases/compiler/commentsOnObjectLiteral2.ts(1,14): error TS2304: Cannot find name 'makeClass'. -tests/cases/compiler/commentsOnObjectLiteral2.ts(9,17): error TS2339: Property 'name' does not exist on type '{ initialize: (name: any) => void; }'. -==== tests/cases/compiler/commentsOnObjectLiteral2.ts (2 errors) ==== +==== tests/cases/compiler/commentsOnObjectLiteral2.ts (1 errors) ==== var Person = makeClass( ~~~~~~~~~ !!! error TS2304: Cannot find name 'makeClass'. @@ -14,8 +13,6 @@ tests/cases/compiler/commentsOnObjectLiteral2.ts(9,17): error TS2339: Property ' */ initialize: function(name) { this.name = name; - ~~~~ -!!! error TS2339: Property 'name' does not exist on type '{ initialize: (name: any) => void; }'. } /* trailing comment 1*/, } ); \ No newline at end of file diff --git a/tests/baselines/reference/fixSignatureCaching.errors.txt b/tests/baselines/reference/fixSignatureCaching.errors.txt index 284a0d13926..7a5c43c966e 100644 --- a/tests/baselines/reference/fixSignatureCaching.errors.txt +++ b/tests/baselines/reference/fixSignatureCaching.errors.txt @@ -41,51 +41,19 @@ tests/cases/conformance/fixSignatureCaching.ts(639,38): error TS2304: Cannot fin tests/cases/conformance/fixSignatureCaching.ts(640,13): error TS2304: Cannot find name 'window'. tests/cases/conformance/fixSignatureCaching.ts(641,13): error TS2304: Cannot find name 'window'. tests/cases/conformance/fixSignatureCaching.ts(704,18): error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(704,45): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(704,58): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(704,67): error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(705,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(734,18): error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(734,45): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(734,58): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(734,67): error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(735,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(783,18): error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(783,45): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(783,58): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(783,67): error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(784,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(804,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(805,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(805,46): error TS2339: Property 'findMatch' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(805,61): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(805,89): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(807,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(827,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(828,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(828,47): error TS2339: Property 'findMatches' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(828,64): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(828,92): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(830,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(844,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(845,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(845,39): error TS2339: Property 'detectOS' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(845,53): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(847,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(869,25): error TS2339: Property 'getVersion' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(869,46): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(890,25): error TS2339: Property 'getVersionStr' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(890,49): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(912,36): error TS2339: Property 'findMatches' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(912,53): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(912,83): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(927,38): error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(941,33): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. -tests/cases/conformance/fixSignatureCaching.ts(941,68): error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(951,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. -tests/cases/conformance/fixSignatureCaching.ts(952,22): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(952,42): error TS2339: Property 'mobileGrade' does not exist on type '{}'. -tests/cases/conformance/fixSignatureCaching.ts(954,25): error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. tests/cases/conformance/fixSignatureCaching.ts(959,16): error TS2304: Cannot find name 'window'. tests/cases/conformance/fixSignatureCaching.ts(959,42): error TS2304: Cannot find name 'window'. tests/cases/conformance/fixSignatureCaching.ts(960,22): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. @@ -103,7 +71,7 @@ tests/cases/conformance/fixSignatureCaching.ts(979,23): error TS2304: Cannot fin tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot find name 'window'. -==== tests/cases/conformance/fixSignatureCaching.ts (103 errors) ==== +==== tests/cases/conformance/fixSignatureCaching.ts (71 errors) ==== // Repro from #10697 (function (define, undefined) { @@ -894,15 +862,7 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. - ~~~~~~~~~~~~~ -!!! error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. return this._cache.mobile; - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -934,15 +894,7 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. - ~~~~~~~~~~~~~ -!!! error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. return this._cache.phone; - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -993,15 +945,7 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. - ~~~~~~~~~~~~~ -!!! error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. return this._cache.tablet; - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1022,21 +966,13 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin */ userAgent: function () { if (this._cache.userAgent === undefined) { - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. this._cache.userAgent = impl.findMatch(impl.mobileDetectRules.uas, this.ua); - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. } return this._cache.userAgent; - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1057,21 +993,13 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin */ userAgents: function () { if (this._cache.userAgents === undefined) { - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. this._cache.userAgents = impl.findMatches(impl.mobileDetectRules.uas, this.ua); - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. } return this._cache.userAgents; - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1086,19 +1014,11 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin */ os: function () { if (this._cache.os === undefined) { - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. this._cache.os = impl.detectOS(this.ua); - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. ~~~~~~~~ !!! error TS2339: Property 'detectOS' does not exist on type '{}'. - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. } return this._cache.os; - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1123,8 +1043,6 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin return impl.getVersion(key, this.ua); ~~~~~~~~~~ !!! error TS2339: Property 'getVersion' does not exist on type '{}'. - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1148,8 +1066,6 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin return impl.getVersionStr(key, this.ua); ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1176,8 +1092,6 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1193,8 +1107,6 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin pattern = new RegExp(pattern, 'i'); } return pattern.test(this.ua); - ~~ -!!! error TS2339: Property 'ua' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1211,8 +1123,6 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin return MobileDetect.isPhoneSized(maxPhoneWidth || this.maxPhoneWidth); ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. - ~~~~~~~~~~~~~ -!!! error TS2339: Property 'maxPhoneWidth' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. }, /** @@ -1223,17 +1133,11 @@ tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot fin */ mobileGrade: function () { if (this._cache.grade === undefined) { - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. this._cache.grade = impl.mobileGrade(this); - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. ~~~~~~~~~~~ !!! error TS2339: Property 'mobileGrade' does not exist on type '{}'. } return this._cache.grade; - ~~~~~~ -!!! error TS2339: Property '_cache' does not exist on type '{ constructor: (userAgent: any, maxPhoneWidth: any) => void; mobile: () => any; phone: () => any; tablet: () => any; userAgent: () => any; userAgents: () => any; os: () => any; version: (key: any) => any; versionStr: (key: any) => any; is: (key: any) => any; match: (pattern: any) => any; isPhoneSized: (maxPhoneWidth: any) => any; mobileGrade: () => any; }'. } }; diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index a734066d5e7..0538121e90c 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -200,9 +200,9 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } } >plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) >c : Symbol(c, Decl(objectSpread.ts, 45, 3)) >plus : Symbol(plus, Decl(objectSpread.ts, 49, 48)) ->this.p : Symbol(C.p, Decl(objectSpread.ts, 44, 9)) ->this : Symbol(cplus, Decl(objectSpread.ts, 49, 40)) ->p : Symbol(C.p, Decl(objectSpread.ts, 44, 9)) +>this.p : Symbol(p, Decl(objectSpread.ts, 49, 12)) +>this : Symbol(cplus, Decl(objectSpread.ts, 49, 10)) +>p : Symbol(p, Decl(objectSpread.ts, 49, 12)) cplus.plus(); >cplus.plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index b6ad1d13ae4..3a736721425 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -268,7 +268,7 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } } >plus : () => number >this.p + 1 : number >this.p : number ->this : { plus(): number; p: number; } +>this : { p: number; plus(): void; } >p : number >1 : 1 diff --git a/tests/baselines/reference/thisTypeInFunctions2.symbols b/tests/baselines/reference/thisTypeInFunctions2.symbols index d9d0be723b6..6811ef4a234 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.symbols +++ b/tests/baselines/reference/thisTypeInFunctions2.symbols @@ -90,12 +90,10 @@ extend2({ >init : Symbol(init, Decl(thisTypeInFunctions2.ts, 32, 9)) this // this: containing object literal type ->this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 32, 8)) +>this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) this.mine ->this.mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) ->this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 32, 8)) ->mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) +>this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) //this.willDestroy }, @@ -106,12 +104,10 @@ extend2({ >foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 38, 13)) this // this: containing object literal type ->this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 32, 8)) +>this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) this.mine ->this.mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) ->this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 32, 8)) ->mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) +>this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) } }); @@ -126,9 +122,9 @@ simple({ >n.length : Symbol(String.length, Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(thisTypeInFunctions2.ts, 46, 8)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->this.bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 48, 6)) ->this : Symbol(__object, Decl(thisTypeInFunctions2.ts, 45, 7)) ->bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 48, 6)) +>this.bar : Symbol(SimpleInterface.bar, Decl(thisTypeInFunctions2.ts, 13, 19)) +>this : Symbol(SimpleInterface, Decl(thisTypeInFunctions2.ts, 11, 1)) +>bar : Symbol(SimpleInterface.bar, Decl(thisTypeInFunctions2.ts, 13, 19)) }, bar() { diff --git a/tests/baselines/reference/thisTypeInFunctions2.types b/tests/baselines/reference/thisTypeInFunctions2.types index f79426529ea..79169a715d5 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.types +++ b/tests/baselines/reference/thisTypeInFunctions2.types @@ -100,12 +100,12 @@ extend2({ >init : () => void this // this: containing object literal type ->this : { init(): void; mine: number; foo(): void; } +>this : IndexedWithoutThis this.mine ->this.mine : number ->this : { init(): void; mine: number; foo(): void; } ->mine : number +>this.mine : any +>this : IndexedWithoutThis +>mine : any //this.willDestroy }, @@ -117,12 +117,12 @@ extend2({ >foo : () => void this // this: containing object literal type ->this : { init(): void; mine: number; foo(): void; } +>this : IndexedWithoutThis this.mine ->this.mine : number ->this : { init(): void; mine: number; foo(): void; } ->mine : number +>this.mine : any +>this : IndexedWithoutThis +>mine : any } }); @@ -142,7 +142,7 @@ simple({ >length : number >this.bar() : number >this.bar : () => number ->this : { foo(n: string): number; bar(): number; } +>this : SimpleInterface >bar : () => number }, From 20b4523d0ffa92454ddb3ed683c8c89a14e46ef5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 24 Feb 2017 19:52:22 -0800 Subject: [PATCH 041/167] Rename applyToContextualType to mapType and remove old mapType --- src/compiler/checker.ts | 60 +++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0218f21a27f..f451871d2bb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10041,8 +10041,31 @@ namespace ts { return f(type) ? type : neverType; } - function mapType(type: Type, f: (t: Type) => Type): Type { - return type.flags & TypeFlags.Union ? getUnionType(map((type).types, f)) : f(type); + // Apply a mapping function to a contextual type and return the resulting type. If the contextual type + // is a union type, the mapping function is applied to each constituent type and a union of the resulting + // types is returned. + function mapType(type: Type, mapper: (t: Type) => Type): Type { + if (!(type.flags & TypeFlags.Union)) { + return mapper(type); + } + const types = (type).types; + let mappedType: Type; + let mappedTypes: Type[]; + for (const current of types) { + const t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; } function extractTypesOfKind(type: Type, kind: TypeFlags) { @@ -11491,7 +11514,7 @@ namespace ts { } function getThisTypeFromContextualType(type: Type): Type { - return applyToContextualType(type, t => { + return mapType(type, t => { return t.flags & TypeFlags.Intersection ? forEach((t).types, getThisTypeArgument) : getThisTypeArgument(t); }); } @@ -11739,42 +11762,15 @@ namespace ts { return undefined; } - // Apply a mapping function to a contextual type and return the resulting type. If the contextual type - // is a union type, the mapping function is applied to each constituent type and a union of the resulting - // types is returned. - function applyToContextualType(type: Type, mapper: (t: Type) => Type): Type { - if (!(type.flags & TypeFlags.Union)) { - return mapper(type); - } - const types = (type).types; - let mappedType: Type; - let mappedTypes: Type[]; - for (const current of types) { - const t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } - function getTypeOfPropertyOfContextualType(type: Type, name: string) { - return applyToContextualType(type, t => { + return mapType(type, t => { const prop = t.flags & TypeFlags.StructuredType ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type: Type, kind: IndexKind) { - return applyToContextualType(type, t => getIndexTypeOfStructuredType(t, kind)); + return mapType(type, t => getIndexTypeOfStructuredType(t, kind)); } // Return true if the given contextual type is a tuple-like type From 6fdd929a66ef6cb9eb7ec5b092b079ac1eb4b0ff Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 24 Feb 2017 19:52:50 -0800 Subject: [PATCH 042/167] Update test --- tests/baselines/reference/thisTypeInFunctions2.js | 2 -- .../reference/thisTypeInFunctions2.symbols | 13 ++++++------- .../baselines/reference/thisTypeInFunctions2.types | 5 ++--- .../types/thisType/thisTypeInFunctions2.ts | 1 - 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/tests/baselines/reference/thisTypeInFunctions2.js b/tests/baselines/reference/thisTypeInFunctions2.js index 45b26fe84d8..978f79483b0 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.js +++ b/tests/baselines/reference/thisTypeInFunctions2.js @@ -35,7 +35,6 @@ extend2({ init() { this // this: containing object literal type this.mine - //this.willDestroy }, mine: 13, foo() { @@ -71,7 +70,6 @@ extend2({ init: function () { this; // this: containing object literal type this.mine; - //this.willDestroy }, mine: 13, foo: function () { diff --git a/tests/baselines/reference/thisTypeInFunctions2.symbols b/tests/baselines/reference/thisTypeInFunctions2.symbols index 6811ef4a234..d4b19caddb4 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.symbols +++ b/tests/baselines/reference/thisTypeInFunctions2.symbols @@ -95,13 +95,12 @@ extend2({ this.mine >this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) - //this.willDestroy }, mine: 13, ->mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) +>mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 36, 6)) foo() { ->foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 38, 13)) +>foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 37, 13)) this // this: containing object literal type >this : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) @@ -115,12 +114,12 @@ simple({ >simple : Symbol(simple, Decl(thisTypeInFunctions2.ts, 17, 57)) foo(n) { ->foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 45, 8)) ->n : Symbol(n, Decl(thisTypeInFunctions2.ts, 46, 8)) +>foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 44, 8)) +>n : Symbol(n, Decl(thisTypeInFunctions2.ts, 45, 8)) return n.length + this.bar(); >n.length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->n : Symbol(n, Decl(thisTypeInFunctions2.ts, 46, 8)) +>n : Symbol(n, Decl(thisTypeInFunctions2.ts, 45, 8)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) >this.bar : Symbol(SimpleInterface.bar, Decl(thisTypeInFunctions2.ts, 13, 19)) >this : Symbol(SimpleInterface, Decl(thisTypeInFunctions2.ts, 11, 1)) @@ -128,7 +127,7 @@ simple({ }, bar() { ->bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 48, 6)) +>bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 47, 6)) return 14; } diff --git a/tests/baselines/reference/thisTypeInFunctions2.types b/tests/baselines/reference/thisTypeInFunctions2.types index 79169a715d5..a527429ccd9 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.types +++ b/tests/baselines/reference/thisTypeInFunctions2.types @@ -92,9 +92,9 @@ extend1({ } }); extend2({ ->extend2({ init() { this // this: containing object literal type this.mine //this.willDestroy }, mine: 13, foo() { this // this: containing object literal type this.mine }}) : void +>extend2({ init() { this // this: containing object literal type this.mine }, mine: 13, foo() { this // this: containing object literal type this.mine }}) : void >extend2 : (args: IndexedWithoutThis) => void ->{ init() { this // this: containing object literal type this.mine //this.willDestroy }, mine: 13, foo() { this // this: containing object literal type this.mine }} : { init(): void; mine: number; foo(): void; } +>{ init() { this // this: containing object literal type this.mine }, mine: 13, foo() { this // this: containing object literal type this.mine }} : { init(): void; mine: number; foo(): void; } init() { >init : () => void @@ -107,7 +107,6 @@ extend2({ >this : IndexedWithoutThis >mine : any - //this.willDestroy }, mine: 13, >mine : number diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts index 0d1581633c3..1c80e21aa16 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts @@ -34,7 +34,6 @@ extend2({ init() { this // this: containing object literal type this.mine - //this.willDestroy }, mine: 13, foo() { From efcca8ce468d2245faa087e30255cb99f4e89479 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Sat, 25 Feb 2017 13:02:56 -0800 Subject: [PATCH 043/167] Make server target depend on services inputs --- Jakefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 78516f60731..f8be7c2b671 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -587,7 +587,7 @@ var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js"); compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false }); var serverFile = path.join(builtLocalDirectory, "tsserver.js"); -compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true }); +compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); compileFile( From 27675fc96e6da8dbb7d7a328def8a07c1a73e37f Mon Sep 17 00:00:00 2001 From: Oleg Mihailik Date: Sat, 25 Feb 2017 23:35:24 +0000 Subject: [PATCH 044/167] Avoid failing TS2695 for eval. --- src/compiler/checker.ts | 2 +- tests/cases/compiler/evalAfter0.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/cases/compiler/evalAfter0.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac5012a3bf9..15782e13610 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15929,7 +15929,7 @@ namespace ts { checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case SyntaxKind.CommaToken: - if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { + if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && right.text!=="eval") { error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; diff --git a/tests/cases/compiler/evalAfter0.ts b/tests/cases/compiler/evalAfter0.ts new file mode 100644 index 00000000000..ff9a036faca --- /dev/null +++ b/tests/cases/compiler/evalAfter0.ts @@ -0,0 +1,3 @@ +(0,eval)("10"); + +(0,alert)("10"); \ No newline at end of file From 6a88cf0edf01730cb656cb1e97fad9972c2a4fb2 Mon Sep 17 00:00:00 2001 From: Oleg Mihailik Date: Sun, 26 Feb 2017 23:13:50 +0000 Subject: [PATCH 045/167] Better check for right.text, more comments in test --- src/compiler/checker.ts | 6 +++++- tests/cases/compiler/evalAfter0.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 15782e13610..ddb1d371a14 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15929,12 +15929,16 @@ namespace ts { checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); case SyntaxKind.CommaToken: - if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && right.text!=="eval") { + if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; } + function isEvalNode(node: Expression) { + return node.kind === SyntaxKind.Identifier && (node as Identifier).text === "eval"; + } + // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { const offendingSymbolOperand = diff --git a/tests/cases/compiler/evalAfter0.ts b/tests/cases/compiler/evalAfter0.ts index ff9a036faca..98c0ea78f7d 100644 --- a/tests/cases/compiler/evalAfter0.ts +++ b/tests/cases/compiler/evalAfter0.ts @@ -1,3 +1,3 @@ -(0,eval)("10"); +(0,eval)("10"); // fine: special case for eval -(0,alert)("10"); \ No newline at end of file +(0,alert)("10"); // error: no side effect left of comma (suspect of missing method name or something) \ No newline at end of file From baef2aa2c17c59669038525e95010581ac273fe1 Mon Sep 17 00:00:00 2001 From: Oleg Mihailik Date: Mon, 27 Feb 2017 01:05:56 +0000 Subject: [PATCH 046/167] Baseline accept --- tests/baselines/reference/evalAfter0.errors.txt | 10 ++++++++++ tests/baselines/reference/evalAfter0.js | 9 +++++++++ tests/cases/compiler/evalAfter0.ts | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/evalAfter0.errors.txt create mode 100644 tests/baselines/reference/evalAfter0.js diff --git a/tests/baselines/reference/evalAfter0.errors.txt b/tests/baselines/reference/evalAfter0.errors.txt new file mode 100644 index 00000000000..448772eda08 --- /dev/null +++ b/tests/baselines/reference/evalAfter0.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/evalAfter0.ts(4,2): error TS2695: Left side of comma operator is unused and has no side effects. + + +==== tests/cases/compiler/evalAfter0.ts (1 errors) ==== + (0,eval)("10"); // fine: special case for eval + + declare var eva; + (0,eva)("10"); // error: no side effect left of comma (suspect of missing method name or something) + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. \ No newline at end of file diff --git a/tests/baselines/reference/evalAfter0.js b/tests/baselines/reference/evalAfter0.js new file mode 100644 index 00000000000..aeaa8f6476c --- /dev/null +++ b/tests/baselines/reference/evalAfter0.js @@ -0,0 +1,9 @@ +//// [evalAfter0.ts] +(0,eval)("10"); // fine: special case for eval + +declare var eva; +(0,eva)("10"); // error: no side effect left of comma (suspect of missing method name or something) + +//// [evalAfter0.js] +(0, eval)("10"); // fine: special case for eval +(0, eva)("10"); // error: no side effect left of comma (suspect of missing method name or something) diff --git a/tests/cases/compiler/evalAfter0.ts b/tests/cases/compiler/evalAfter0.ts index 98c0ea78f7d..2245150ce6a 100644 --- a/tests/cases/compiler/evalAfter0.ts +++ b/tests/cases/compiler/evalAfter0.ts @@ -1,3 +1,4 @@ (0,eval)("10"); // fine: special case for eval -(0,alert)("10"); // error: no side effect left of comma (suspect of missing method name or something) \ No newline at end of file +declare var eva; +(0,eva)("10"); // error: no side effect left of comma (suspect of missing method name or something) \ No newline at end of file From c2f4b202a4e9d4940cc2331dbdd1fafed1bae610 Mon Sep 17 00:00:00 2001 From: andy-ms Date: Sun, 26 Feb 2017 17:47:39 -0800 Subject: [PATCH 047/167] Add more specific return type for `getTypeParameters()` --- src/services/services.ts | 2 +- src/services/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 0c7b5d97d26..f122e39bcc6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -412,7 +412,7 @@ namespace ts { getDeclaration(): SignatureDeclaration { return this.declaration; } - getTypeParameters(): Type[] { + getTypeParameters(): TypeParameter[] { return this.typeParameters; } getParameters(): Symbol[] { diff --git a/src/services/types.ts b/src/services/types.ts index a577fb20aac..9253153c004 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -39,7 +39,7 @@ namespace ts { export interface Signature { getDeclaration(): SignatureDeclaration; - getTypeParameters(): Type[]; + getTypeParameters(): TypeParameter[]; getParameters(): Symbol[]; getReturnType(): Type; getDocumentationComment(): SymbolDisplayPart[]; From d7461c874b5fa40e166ac4efd1127049a7df0ca8 Mon Sep 17 00:00:00 2001 From: mihailik Date: Mon, 27 Feb 2017 08:39:01 +0000 Subject: [PATCH 048/167] Promise is a duplicate here - fails to build --- Gulpfile.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 7e7f05fd9c4..633a1387ab6 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -21,10 +21,6 @@ declare module "gulp-typescript" { import * as insert from "gulp-insert"; import * as sourcemaps from "gulp-sourcemaps"; import Q = require("q"); -declare global { - // `del` further depends on `Promise` (and is also not included), so we just, patch the global scope's Promise to Q's (which we already include in our deps because gulp depends on it) - type Promise = Q.Promise; -} import del = require("del"); import mkdirP = require("mkdirp"); import minimist = require("minimist"); From cd87d903a022a5aa2e94f57cb7fb9abc646aa61e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 27 Feb 2017 10:19:14 -0800 Subject: [PATCH 049/167] Update comment --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f451871d2bb..ff3a1079b18 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10041,9 +10041,9 @@ namespace ts { return f(type) ? type : neverType; } - // Apply a mapping function to a contextual type and return the resulting type. If the contextual type - // is a union type, the mapping function is applied to each constituent type and a union of the resulting - // types is returned. + // Apply a mapping function to a type and return the resulting type. If the source type + // is a union type, the mapping function is applied to each constituent type and a union + // of the resulting types is returned. function mapType(type: Type, mapper: (t: Type) => Type): Type { if (!(type.flags & TypeFlags.Union)) { return mapper(type); From 5bda48ba8d44717cb7038c70d365438de69ce09b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 27 Feb 2017 10:19:26 -0800 Subject: [PATCH 050/167] Add tests --- .../reference/thisTypeInObjectLiterals2.js | 293 +++++++++++ .../thisTypeInObjectLiterals2.symbols | 410 ++++++++++++++++ .../reference/thisTypeInObjectLiterals2.types | 463 ++++++++++++++++++ .../thisType/thisTypeInObjectLiterals2.ts | 144 ++++++ 4 files changed, 1310 insertions(+) create mode 100644 tests/baselines/reference/thisTypeInObjectLiterals2.js create mode 100644 tests/baselines/reference/thisTypeInObjectLiterals2.symbols create mode 100644 tests/baselines/reference/thisTypeInObjectLiterals2.types create mode 100644 tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.js b/tests/baselines/reference/thisTypeInObjectLiterals2.js new file mode 100644 index 00000000000..08f02b6c5af --- /dev/null +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.js @@ -0,0 +1,293 @@ +//// [thisTypeInObjectLiterals2.ts] + +// In methods of an object literal with no contextual type, 'this' has the type +// of the object literal. + +let obj1 = { + a: 1, + f() { + return this.a; + }, + b: "hello", + c: { + g() { + this.g(); + } + }, + get d() { + return this.a; + }, + get e() { + return this.b; + }, + set e(value) { + this.b = value; + } +}; + +// In methods of an object literal with a contextual type, 'this' has the +// contextual type. + +type Point = { + x: number; + y: number; + moveBy(dx: number, dy: number): void; +} + +let p1: Point = { + x: 10, + y: 20, + moveBy(dx, dy) { + this.x += dx; + this.y += dy; + } +}; + +declare function f1(p: Point): void; + +f1({ + x: 10, + y: 20, + moveBy(dx, dy) { + this.x += dx; + this.y += dy; + } +}); + +// In methods of an object literal with a contextual type that includes some +// ThisType, 'this' is of type T. + +type ObjectDescriptor = { + data?: D; + methods?: M & ThisType; // Type of 'this' in methods is D & M +} + +declare function makeObject(desc: ObjectDescriptor): D & M; + +let x1 = makeObject({ + data: { x: 0, y: 0 }, + methods: { + moveBy(dx: number, dy: number) { + this.x += dx; // Strongly typed this + this.y += dy; // Strongly typed this + } + } +}); + +// In methods contained in an object literal with a contextual type that includes +// some ThisType, 'this' is of type T. + +type ObjectDescriptor2 = ThisType & { + data?: D; + methods?: M; +} + +declare function makeObject2(desc: ObjectDescriptor): D & M; + +let x2 = makeObject2({ + data: { x: 0, y: 0 }, + methods: { + moveBy(dx: number, dy: number) { + this.x += dx; // Strongly typed this + this.y += dy; // Strongly typed this + } + } +}); + +// Proof of concept for typing of Vue.js + +type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; + +type Dictionary = { [x: string]: T } + +type Computed = { + get?(): T; + set?(value: T): void; +} + +type VueOptions = ThisType & { + data?: D | (() => D); + methods?: M; + computed?: Accessors

; +} + +declare const Vue: new (options: VueOptions) => D & M & P; + +let vue = new Vue({ + data: () => ({ x: 1, y: 2 }), + methods: { + f(x: string) { + return this.x; + } + }, + computed: { + test(): number { + return this.x; + }, + hello: { + get() { + return "hi"; + }, + set(value: string) { + } + } + } +}); + +vue; +vue.x; +vue.f("abc"); +vue.test; +vue.hello; + + +//// [thisTypeInObjectLiterals2.js] +// In methods of an object literal with no contextual type, 'this' has the type +// of the object literal. +var obj1 = { + a: 1, + f: function () { + return this.a; + }, + b: "hello", + c: { + g: function () { + this.g(); + } + }, + get d() { + return this.a; + }, + get e() { + return this.b; + }, + set e(value) { + this.b = value; + } +}; +var p1 = { + x: 10, + y: 20, + moveBy: function (dx, dy) { + this.x += dx; + this.y += dy; + } +}; +f1({ + x: 10, + y: 20, + moveBy: function (dx, dy) { + this.x += dx; + this.y += dy; + } +}); +var x1 = makeObject({ + data: { x: 0, y: 0 }, + methods: { + moveBy: function (dx, dy) { + this.x += dx; // Strongly typed this + this.y += dy; // Strongly typed this + } + } +}); +var x2 = makeObject2({ + data: { x: 0, y: 0 }, + methods: { + moveBy: function (dx, dy) { + this.x += dx; // Strongly typed this + this.y += dy; // Strongly typed this + } + } +}); +var vue = new Vue({ + data: function () { return ({ x: 1, y: 2 }); }, + methods: { + f: function (x) { + return this.x; + } + }, + computed: { + test: function () { + return this.x; + }, + hello: { + get: function () { + return "hi"; + }, + set: function (value) { + } + } + } +}); +vue; +vue.x; +vue.f("abc"); +vue.test; +vue.hello; + + +//// [thisTypeInObjectLiterals2.d.ts] +declare let obj1: { + a: number; + f(): number; + b: string; + c: { + g(): void; + }; + readonly d: number; + e: string; +}; +declare type Point = { + x: number; + y: number; + moveBy(dx: number, dy: number): void; +}; +declare let p1: Point; +declare function f1(p: Point): void; +declare type ObjectDescriptor = { + data?: D; + methods?: M & ThisType; +}; +declare function makeObject(desc: ObjectDescriptor): D & M; +declare let x1: { + x: number; + y: number; +} & { + moveBy(dx: number, dy: number): void; +}; +declare type ObjectDescriptor2 = ThisType & { + data?: D; + methods?: M; +}; +declare function makeObject2(desc: ObjectDescriptor): D & M; +declare let x2: { + x: number; + y: number; +} & { + moveBy(dx: number, dy: number): void; +}; +declare type Accessors = { + [K in keyof T]: (() => T[K]) | Computed; +}; +declare type Dictionary = { + [x: string]: T; +}; +declare type Computed = { + get?(): T; + set?(value: T): void; +}; +declare type VueOptions = ThisType & { + data?: D | (() => D); + methods?: M; + computed?: Accessors

; +}; +declare const Vue: new (options: VueOptions) => D & M & P; +declare let vue: { + x: number; + y: number; +} & { + f(x: string): number; +} & { + test: number; + hello: string; +}; diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.symbols b/tests/baselines/reference/thisTypeInObjectLiterals2.symbols new file mode 100644 index 00000000000..ef72c320cce --- /dev/null +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.symbols @@ -0,0 +1,410 @@ +=== tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts === + +// In methods of an object literal with no contextual type, 'this' has the type +// of the object literal. + +let obj1 = { +>obj1 : Symbol(obj1, Decl(thisTypeInObjectLiterals2.ts, 4, 3)) + + a: 1, +>a : Symbol(a, Decl(thisTypeInObjectLiterals2.ts, 4, 12)) + + f() { +>f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 5, 9)) + + return this.a; +>this.a : Symbol(a, Decl(thisTypeInObjectLiterals2.ts, 4, 12)) +>this : Symbol(obj1, Decl(thisTypeInObjectLiterals2.ts, 4, 10)) +>a : Symbol(a, Decl(thisTypeInObjectLiterals2.ts, 4, 12)) + + }, + b: "hello", +>b : Symbol(b, Decl(thisTypeInObjectLiterals2.ts, 8, 6)) + + c: { +>c : Symbol(c, Decl(thisTypeInObjectLiterals2.ts, 9, 15)) + + g() { +>g : Symbol(g, Decl(thisTypeInObjectLiterals2.ts, 10, 8)) + + this.g(); +>this.g : Symbol(g, Decl(thisTypeInObjectLiterals2.ts, 10, 8)) +>this : Symbol(__object, Decl(thisTypeInObjectLiterals2.ts, 10, 6)) +>g : Symbol(g, Decl(thisTypeInObjectLiterals2.ts, 10, 8)) + } + }, + get d() { +>d : Symbol(d, Decl(thisTypeInObjectLiterals2.ts, 14, 6)) + + return this.a; +>this.a : Symbol(a, Decl(thisTypeInObjectLiterals2.ts, 4, 12)) +>this : Symbol(obj1, Decl(thisTypeInObjectLiterals2.ts, 4, 10)) +>a : Symbol(a, Decl(thisTypeInObjectLiterals2.ts, 4, 12)) + + }, + get e() { +>e : Symbol(e, Decl(thisTypeInObjectLiterals2.ts, 17, 6), Decl(thisTypeInObjectLiterals2.ts, 20, 6)) + + return this.b; +>this.b : Symbol(b, Decl(thisTypeInObjectLiterals2.ts, 8, 6)) +>this : Symbol(obj1, Decl(thisTypeInObjectLiterals2.ts, 4, 10)) +>b : Symbol(b, Decl(thisTypeInObjectLiterals2.ts, 8, 6)) + + }, + set e(value) { +>e : Symbol(e, Decl(thisTypeInObjectLiterals2.ts, 17, 6), Decl(thisTypeInObjectLiterals2.ts, 20, 6)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 21, 10)) + + this.b = value; +>this.b : Symbol(b, Decl(thisTypeInObjectLiterals2.ts, 8, 6)) +>this : Symbol(obj1, Decl(thisTypeInObjectLiterals2.ts, 4, 10)) +>b : Symbol(b, Decl(thisTypeInObjectLiterals2.ts, 8, 6)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 21, 10)) + } +}; + +// In methods of an object literal with a contextual type, 'this' has the +// contextual type. + +type Point = { +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + + x: number; +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) + + y: number; +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) + + moveBy(dx: number, dy: number): void; +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 32, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 32, 22)) +} + +let p1: Point = { +>p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 35, 3)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 35, 17)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 36, 10)) + + moveBy(dx, dy) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 37, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 38, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 38, 14)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 38, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 38, 14)) + } +}; + +declare function f1(p: Point): void; +>f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 42, 2)) +>p : Symbol(p, Decl(thisTypeInObjectLiterals2.ts, 44, 20)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + +f1({ +>f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 42, 2)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 46, 4)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 47, 10)) + + moveBy(dx, dy) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 48, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 49, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 49, 14)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 49, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 49, 14)) + } +}); + +// In methods of an object literal with a contextual type that includes some +// ThisType, 'this' is of type T. + +type ObjectDescriptor = { +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 53, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 58, 22)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 58, 24)) + + data?: D; +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 58, 31)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 58, 22)) + + methods?: M & ThisType; // Type of 'this' in methods is D & M +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 59, 13)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 58, 24)) +>ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 58, 22)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 58, 24)) +} + +declare function makeObject(desc: ObjectDescriptor): D & M; +>makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 61, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 63, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 63, 30)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 63, 34)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 53, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 63, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 63, 30)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 63, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 63, 30)) + +let x1 = makeObject({ +>x1 : Symbol(x1, Decl(thisTypeInObjectLiterals2.ts, 65, 3)) +>makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 61, 1)) + + data: { x: 0, y: 0 }, +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 65, 21)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 66, 11)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 66, 17)) + + methods: { +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 66, 25)) + + moveBy(dx: number, dy: number) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 67, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 68, 15)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 68, 26)) + + this.x += dx; // Strongly typed this +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 66, 11)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 66, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 68, 15)) + + this.y += dy; // Strongly typed this +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 66, 17)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 66, 17)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 68, 26)) + } + } +}); + +// In methods contained in an object literal with a contextual type that includes +// some ThisType, 'this' is of type T. + +type ObjectDescriptor2 = ThisType & { +>ObjectDescriptor2 : Symbol(ObjectDescriptor2, Decl(thisTypeInObjectLiterals2.ts, 73, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 78, 23)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 78, 25)) +>ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 78, 23)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 78, 25)) + + data?: D; +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 78, 50)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 78, 23)) + + methods?: M; +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 79, 13)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 78, 25)) +} + +declare function makeObject2(desc: ObjectDescriptor): D & M; +>makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 81, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 83, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 83, 31)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 83, 35)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 53, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 83, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 83, 31)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 83, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 83, 31)) + +let x2 = makeObject2({ +>x2 : Symbol(x2, Decl(thisTypeInObjectLiterals2.ts, 85, 3)) +>makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 81, 1)) + + data: { x: 0, y: 0 }, +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 85, 22)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 86, 11)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 86, 17)) + + methods: { +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 86, 25)) + + moveBy(dx: number, dy: number) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 87, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 88, 15)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 88, 26)) + + this.x += dx; // Strongly typed this +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 86, 11)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 86, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 88, 15)) + + this.y += dy; // Strongly typed this +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 86, 17)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 86, 17)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 88, 26)) + } + } +}); + +// Proof of concept for typing of Vue.js + +type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; +>Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 93, 3)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 97, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 97, 23)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 97, 15)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 97, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 97, 23)) +>Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 99, 39)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 97, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 97, 23)) + +type Dictionary = { [x: string]: T } +>Dictionary : Symbol(Dictionary, Decl(thisTypeInObjectLiterals2.ts, 97, 70)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 99, 16)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 99, 24)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 99, 16)) + +type Computed = { +>Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 99, 39)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 101, 14)) + + get?(): T; +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 101, 20)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 101, 14)) + + set?(value: T): void; +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 102, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 103, 9)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 101, 14)) +} + +type VueOptions = ThisType & { +>VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 104, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 106, 16)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 106, 18)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 106, 21)) +>ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 106, 16)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 106, 18)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 106, 21)) + + data?: D | (() => D); +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 106, 50)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 106, 16)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 106, 16)) + + methods?: M; +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 107, 25)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 106, 18)) + + computed?: Accessors

; +>computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 108, 16)) +>Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 93, 3)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 106, 21)) +} + +declare const Vue: new (options: VueOptions) => D & M & P; +>Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 112, 13)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 112, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 112, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 112, 29)) +>options : Symbol(options, Decl(thisTypeInObjectLiterals2.ts, 112, 33)) +>VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 104, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 112, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 112, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 112, 29)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 112, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 112, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 112, 29)) + +let vue = new Vue({ +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) +>Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 112, 13)) + + data: () => ({ x: 1, y: 2 }), +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 114, 19)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 115, 24)) + + methods: { +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 115, 33)) + + f(x: string) { +>f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 116, 14)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 117, 10)) + + return this.x; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) + } + }, + computed: { +>computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 120, 6)) + + test(): number { +>test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 121, 15)) + + return this.x; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) + + }, + hello: { +>hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 124, 10)) + + get() { +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 125, 16)) + + return "hi"; + }, + set(value: string) { +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 128, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 129, 16)) + } + } + } +}); + +vue; +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) + +vue.x; +>vue.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) + +vue.f("abc"); +>vue.f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 116, 14)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) +>f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 116, 14)) + +vue.test; +>vue.test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 121, 15)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) +>test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 121, 15)) + +vue.hello; +>vue.hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 124, 10)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) +>hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 124, 10)) + diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.types b/tests/baselines/reference/thisTypeInObjectLiterals2.types new file mode 100644 index 00000000000..39fd922f617 --- /dev/null +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.types @@ -0,0 +1,463 @@ +=== tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts === + +// In methods of an object literal with no contextual type, 'this' has the type +// of the object literal. + +let obj1 = { +>obj1 : { a: number; f(): number; b: string; c: { g(): void; }; readonly d: number; e: string; } +>{ a: 1, f() { return this.a; }, b: "hello", c: { g() { this.g(); } }, get d() { return this.a; }, get e() { return this.b; }, set e(value) { this.b = value; }} : { a: number; f(): number; b: string; c: { g(): void; }; readonly d: number; e: string; } + + a: 1, +>a : number +>1 : 1 + + f() { +>f : () => number + + return this.a; +>this.a : number +>this : { a: number; f(): number; b: string; c: { g(): void; }; readonly d: number; e: string; } +>a : number + + }, + b: "hello", +>b : string +>"hello" : "hello" + + c: { +>c : { g(): void; } +>{ g() { this.g(); } } : { g(): void; } + + g() { +>g : () => void + + this.g(); +>this.g() : void +>this.g : () => void +>this : { g(): void; } +>g : () => void + } + }, + get d() { +>d : number + + return this.a; +>this.a : number +>this : { a: number; f(): number; b: string; c: { g(): void; }; readonly d: number; e: string; } +>a : number + + }, + get e() { +>e : string + + return this.b; +>this.b : string +>this : { a: number; f(): number; b: string; c: { g(): void; }; readonly d: number; e: string; } +>b : string + + }, + set e(value) { +>e : string +>value : string + + this.b = value; +>this.b = value : string +>this.b : string +>this : { a: number; f(): number; b: string; c: { g(): void; }; readonly d: number; e: string; } +>b : string +>value : string + } +}; + +// In methods of an object literal with a contextual type, 'this' has the +// contextual type. + +type Point = { +>Point : Point + + x: number; +>x : number + + y: number; +>y : number + + moveBy(dx: number, dy: number): void; +>moveBy : (dx: number, dy: number) => void +>dx : number +>dy : number +} + +let p1: Point = { +>p1 : Point +>Point : Point +>{ x: 10, y: 20, moveBy(dx, dy) { this.x += dx; this.y += dy; }} : { x: number; y: number; moveBy(dx: number, dy: number): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy) { +>moveBy : (dx: number, dy: number) => void +>dx : number +>dy : number + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + } +}; + +declare function f1(p: Point): void; +>f1 : (p: Point) => void +>p : Point +>Point : Point + +f1({ +>f1({ x: 10, y: 20, moveBy(dx, dy) { this.x += dx; this.y += dy; }}) : void +>f1 : (p: Point) => void +>{ x: 10, y: 20, moveBy(dx, dy) { this.x += dx; this.y += dy; }} : { x: number; y: number; moveBy(dx: number, dy: number): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy) { +>moveBy : (dx: number, dy: number) => void +>dx : number +>dy : number + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + } +}); + +// In methods of an object literal with a contextual type that includes some +// ThisType, 'this' is of type T. + +type ObjectDescriptor = { +>ObjectDescriptor : ObjectDescriptor +>D : D +>M : M + + data?: D; +>data : D +>D : D + + methods?: M & ThisType; // Type of 'this' in methods is D & M +>methods : M & ThisType +>M : M +>ThisType : ThisType +>D : D +>M : M +} + +declare function makeObject(desc: ObjectDescriptor): D & M; +>makeObject : (desc: ObjectDescriptor) => D & M +>D : D +>M : M +>desc : ObjectDescriptor +>ObjectDescriptor : ObjectDescriptor +>D : D +>M : M +>D : D +>M : M + +let x1 = makeObject({ +>x1 : { x: number; y: number; } & { moveBy(dx: number, dy: number): void; } +>makeObject({ data: { x: 0, y: 0 }, methods: { moveBy(dx: number, dy: number) { this.x += dx; // Strongly typed this this.y += dy; // Strongly typed this } }}) : { x: number; y: number; } & { moveBy(dx: number, dy: number): void; } +>makeObject : (desc: ObjectDescriptor) => D & M +>{ data: { x: 0, y: 0 }, methods: { moveBy(dx: number, dy: number) { this.x += dx; // Strongly typed this this.y += dy; // Strongly typed this } }} : { data: { x: number; y: number; }; methods: { moveBy(dx: number, dy: number): void; }; } + + data: { x: 0, y: 0 }, +>data : { x: number; y: number; } +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + + methods: { +>methods : { moveBy(dx: number, dy: number): void; } +>{ moveBy(dx: number, dy: number) { this.x += dx; // Strongly typed this this.y += dy; // Strongly typed this } } : { moveBy(dx: number, dy: number): void; } + + moveBy(dx: number, dy: number) { +>moveBy : (dx: number, dy: number) => void +>dx : number +>dy : number + + this.x += dx; // Strongly typed this +>this.x += dx : number +>this.x : number +>this : { x: number; y: number; } & { moveBy(dx: number, dy: number): void; } +>x : number +>dx : number + + this.y += dy; // Strongly typed this +>this.y += dy : number +>this.y : number +>this : { x: number; y: number; } & { moveBy(dx: number, dy: number): void; } +>y : number +>dy : number + } + } +}); + +// In methods contained in an object literal with a contextual type that includes +// some ThisType, 'this' is of type T. + +type ObjectDescriptor2 = ThisType & { +>ObjectDescriptor2 : ObjectDescriptor2 +>D : D +>M : M +>ThisType : ThisType +>D : D +>M : M + + data?: D; +>data : D +>D : D + + methods?: M; +>methods : M +>M : M +} + +declare function makeObject2(desc: ObjectDescriptor): D & M; +>makeObject2 : (desc: ObjectDescriptor) => D & M +>D : D +>M : M +>desc : ObjectDescriptor +>ObjectDescriptor : ObjectDescriptor +>D : D +>M : M +>D : D +>M : M + +let x2 = makeObject2({ +>x2 : { x: number; y: number; } & { moveBy(dx: number, dy: number): void; } +>makeObject2({ data: { x: 0, y: 0 }, methods: { moveBy(dx: number, dy: number) { this.x += dx; // Strongly typed this this.y += dy; // Strongly typed this } }}) : { x: number; y: number; } & { moveBy(dx: number, dy: number): void; } +>makeObject2 : (desc: ObjectDescriptor) => D & M +>{ data: { x: 0, y: 0 }, methods: { moveBy(dx: number, dy: number) { this.x += dx; // Strongly typed this this.y += dy; // Strongly typed this } }} : { data: { x: number; y: number; }; methods: { moveBy(dx: number, dy: number): void; }; } + + data: { x: 0, y: 0 }, +>data : { x: number; y: number; } +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + + methods: { +>methods : { moveBy(dx: number, dy: number): void; } +>{ moveBy(dx: number, dy: number) { this.x += dx; // Strongly typed this this.y += dy; // Strongly typed this } } : { moveBy(dx: number, dy: number): void; } + + moveBy(dx: number, dy: number) { +>moveBy : (dx: number, dy: number) => void +>dx : number +>dy : number + + this.x += dx; // Strongly typed this +>this.x += dx : number +>this.x : number +>this : { x: number; y: number; } & { moveBy(dx: number, dy: number): void; } +>x : number +>dx : number + + this.y += dy; // Strongly typed this +>this.y += dy : number +>this.y : number +>this : { x: number; y: number; } & { moveBy(dx: number, dy: number): void; } +>y : number +>dy : number + } + } +}); + +// Proof of concept for typing of Vue.js + +type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; +>Accessors : Accessors +>T : T +>K : K +>T : T +>T : T +>K : K +>Computed : Computed +>T : T +>K : K + +type Dictionary = { [x: string]: T } +>Dictionary : Dictionary +>T : T +>x : string +>T : T + +type Computed = { +>Computed : Computed +>T : T + + get?(): T; +>get : () => T +>T : T + + set?(value: T): void; +>set : (value: T) => void +>value : T +>T : T +} + +type VueOptions = ThisType & { +>VueOptions : VueOptions +>D : D +>M : M +>P : P +>ThisType : ThisType +>D : D +>M : M +>P : P + + data?: D | (() => D); +>data : D | (() => D) +>D : D +>D : D + + methods?: M; +>methods : M +>M : M + + computed?: Accessors

; +>computed : Accessors

+>Accessors : Accessors +>P : P +} + +declare const Vue: new (options: VueOptions) => D & M & P; +>Vue : new (options: VueOptions) => D & M & P +>D : D +>M : M +>P : P +>options : VueOptions +>VueOptions : VueOptions +>D : D +>M : M +>P : P +>D : D +>M : M +>P : P + +let vue = new Vue({ +>vue : { x: number; y: number; } & { f(x: string): number; } & { test: number; hello: string; } +>new Vue({ data: () => ({ x: 1, y: 2 }), methods: { f(x: string) { return this.x; } }, computed: { test(): number { return this.x; }, hello: { get() { return "hi"; }, set(value: string) { } } }}) : { x: number; y: number; } & { f(x: string): number; } & { test: number; hello: string; } +>Vue : new (options: VueOptions) => D & M & P +>{ data: () => ({ x: 1, y: 2 }), methods: { f(x: string) { return this.x; } }, computed: { test(): number { return this.x; }, hello: { get() { return "hi"; }, set(value: string) { } } }} : { data: () => { x: number; y: number; }; methods: { f(x: string): number; }; computed: { test(): number; hello: { get(): string; set(value: string): void; }; }; } + + data: () => ({ x: 1, y: 2 }), +>data : () => { x: number; y: number; } +>() => ({ x: 1, y: 2 }) : () => { x: number; y: number; } +>({ x: 1, y: 2 }) : { x: number; y: number; } +>{ x: 1, y: 2 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>2 : 2 + + methods: { +>methods : { f(x: string): number; } +>{ f(x: string) { return this.x; } } : { f(x: string): number; } + + f(x: string) { +>f : (x: string) => number +>x : string + + return this.x; +>this.x : number +>this : { x: number; y: number; } & { f(x: string): number; } & { test: number; hello: string; } +>x : number + } + }, + computed: { +>computed : { test(): number; hello: { get(): string; set(value: string): void; }; } +>{ test(): number { return this.x; }, hello: { get() { return "hi"; }, set(value: string) { } } } : { test(): number; hello: { get(): string; set(value: string): void; }; } + + test(): number { +>test : () => number + + return this.x; +>this.x : number +>this : { x: number; y: number; } & { f(x: string): number; } & { test: number; hello: string; } +>x : number + + }, + hello: { +>hello : { get(): string; set(value: string): void; } +>{ get() { return "hi"; }, set(value: string) { } } : { get(): string; set(value: string): void; } + + get() { +>get : () => string + + return "hi"; +>"hi" : "hi" + + }, + set(value: string) { +>set : (value: string) => void +>value : string + } + } + } +}); + +vue; +>vue : { x: number; y: number; } & { f(x: string): number; } & { test: number; hello: string; } + +vue.x; +>vue.x : number +>vue : { x: number; y: number; } & { f(x: string): number; } & { test: number; hello: string; } +>x : number + +vue.f("abc"); +>vue.f("abc") : number +>vue.f : (x: string) => number +>vue : { x: number; y: number; } & { f(x: string): number; } & { test: number; hello: string; } +>f : (x: string) => number +>"abc" : "abc" + +vue.test; +>vue.test : number +>vue : { x: number; y: number; } & { f(x: string): number; } & { test: number; hello: string; } +>test : number + +vue.hello; +>vue.hello : string +>vue : { x: number; y: number; } & { f(x: string): number; } & { test: number; hello: string; } +>hello : string + diff --git a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts new file mode 100644 index 00000000000..7358b47259c --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts @@ -0,0 +1,144 @@ +// @declaration: true +// @noImplicitAny: true +// @noImplicitThis: true +// @target: es5 + +// In methods of an object literal with no contextual type, 'this' has the type +// of the object literal. + +let obj1 = { + a: 1, + f() { + return this.a; + }, + b: "hello", + c: { + g() { + this.g(); + } + }, + get d() { + return this.a; + }, + get e() { + return this.b; + }, + set e(value) { + this.b = value; + } +}; + +// In methods of an object literal with a contextual type, 'this' has the +// contextual type. + +type Point = { + x: number; + y: number; + moveBy(dx: number, dy: number): void; +} + +let p1: Point = { + x: 10, + y: 20, + moveBy(dx, dy) { + this.x += dx; + this.y += dy; + } +}; + +declare function f1(p: Point): void; + +f1({ + x: 10, + y: 20, + moveBy(dx, dy) { + this.x += dx; + this.y += dy; + } +}); + +// In methods of an object literal with a contextual type that includes some +// ThisType, 'this' is of type T. + +type ObjectDescriptor = { + data?: D; + methods?: M & ThisType; // Type of 'this' in methods is D & M +} + +declare function makeObject(desc: ObjectDescriptor): D & M; + +let x1 = makeObject({ + data: { x: 0, y: 0 }, + methods: { + moveBy(dx: number, dy: number) { + this.x += dx; // Strongly typed this + this.y += dy; // Strongly typed this + } + } +}); + +// In methods contained in an object literal with a contextual type that includes +// some ThisType, 'this' is of type T. + +type ObjectDescriptor2 = ThisType & { + data?: D; + methods?: M; +} + +declare function makeObject2(desc: ObjectDescriptor): D & M; + +let x2 = makeObject2({ + data: { x: 0, y: 0 }, + methods: { + moveBy(dx: number, dy: number) { + this.x += dx; // Strongly typed this + this.y += dy; // Strongly typed this + } + } +}); + +// Proof of concept for typing of Vue.js + +type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; + +type Dictionary = { [x: string]: T } + +type Computed = { + get?(): T; + set?(value: T): void; +} + +type VueOptions = ThisType & { + data?: D | (() => D); + methods?: M; + computed?: Accessors

; +} + +declare const Vue: new (options: VueOptions) => D & M & P; + +let vue = new Vue({ + data: () => ({ x: 1, y: 2 }), + methods: { + f(x: string) { + return this.x; + } + }, + computed: { + test(): number { + return this.x; + }, + hello: { + get() { + return "hi"; + }, + set(value: string) { + } + } + } +}); + +vue; +vue.x; +vue.f("abc"); +vue.test; +vue.hello; From 8c2bcaedee1ac3d51ec9ce6a9a982d922d889adf Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 27 Feb 2017 11:43:52 -0800 Subject: [PATCH 051/167] Fix emit for downlevel generated catch variable --- src/compiler/transformers/generators.ts | 27 +++-- .../reference/emitter.forAwait.es5.js | 112 +++++++++--------- 2 files changed, 73 insertions(+), 66 deletions(-) diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index ff832188b5b..57e85f50f39 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -1942,7 +1942,7 @@ namespace ts { } function substituteExpressionIdentifier(node: Identifier) { - if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { + if (!isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(node.text)) { const original = getOriginalNode(node); if (isIdentifier(original) && original.parent) { const declaration = resolver.getReferencedValueDeclaration(original); @@ -2108,17 +2108,24 @@ namespace ts { function beginCatchBlock(variable: VariableDeclaration): void { Debug.assert(peekBlockKind() === CodeBlockKind.Exception); - const text = (variable.name).text; - const name = declareLocal(text); - - if (!renamedCatchVariables) { - renamedCatchVariables = createMap(); - renamedCatchVariableDeclarations = []; - context.enableSubstitution(SyntaxKind.Identifier); + // generated identifiers should already be unique within a file + let name: Identifier; + if (isGeneratedIdentifier(variable.name)) { + name = variable.name; + hoistVariableDeclaration(variable.name); } + else { + const text = (variable.name).text; + name = declareLocal(text); + if (!renamedCatchVariables) { + renamedCatchVariables = createMap(); + renamedCatchVariableDeclarations = []; + context.enableSubstitution(SyntaxKind.Identifier); + } - renamedCatchVariables.set(text, true); - renamedCatchVariableDeclarations[getOriginalNodeId(variable)] = name; + renamedCatchVariables.set(text, true); + renamedCatchVariableDeclarations[getOriginalNodeId(variable)] = name; + } const exception = peekBlock(); Debug.assert(exception.state < ExceptionBlockState.Catch); diff --git a/tests/baselines/reference/emitter.forAwait.es5.js b/tests/baselines/reference/emitter.forAwait.es5.js index efbbe872b3f..14b70e933bb 100644 --- a/tests/baselines/reference/emitter.forAwait.es5.js +++ b/tests/baselines/reference/emitter.forAwait.es5.js @@ -68,36 +68,36 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) { }; function f1() { return __awaiter(this, void 0, void 0, function () { - var y, y_1, y_1_1, x, _a, e_1, _b; - return __generator(this, function (_c) { - switch (_c.label) { + var y, y_1, y_1_1, x, e_1_1, e_1, _a; + return __generator(this, function (_b) { + switch (_b.label) { case 0: - _c.trys.push([0, 6, 7, 12]); + _b.trys.push([0, 6, 7, 12]); y_1 = __asyncValues(y); return [4 /*yield*/, y_1.next()]; case 1: - y_1_1 = _c.sent(); - _c.label = 2; + y_1_1 = _b.sent(); + _b.label = 2; case 2: if (!!y_1_1.done) return [3 /*break*/, 5]; x = y_1_1.value; - _c.label = 3; + _b.label = 3; case 3: return [4 /*yield*/, y_1.next()]; case 4: - y_1_1 = _c.sent(); + y_1_1 = _b.sent(); return [3 /*break*/, 2]; case 5: return [3 /*break*/, 12]; case 6: - _a = _c.sent(); + e_1_1 = _b.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 12]; case 7: - _c.trys.push([7, , 10, 11]); - if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; - return [4 /*yield*/, _b.call(y_1)]; + _b.trys.push([7, , 10, 11]); + if (!(y_1_1 && !y_1_1.done && (_a = y_1.return))) return [3 /*break*/, 9]; + return [4 /*yield*/, _a.call(y_1)]; case 8: - _c.sent(); - _c.label = 9; + _b.sent(); + _b.label = 9; case 9: return [3 /*break*/, 11]; case 10: if (e_1) throw e_1.error; @@ -151,36 +151,36 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) { }; function f2() { return __awaiter(this, void 0, void 0, function () { - var x, y, y_1, y_1_1, _a, e_1, _b; - return __generator(this, function (_c) { - switch (_c.label) { + var x, y, y_1, y_1_1, e_1_1, e_1, _a; + return __generator(this, function (_b) { + switch (_b.label) { case 0: - _c.trys.push([0, 6, 7, 12]); + _b.trys.push([0, 6, 7, 12]); y_1 = __asyncValues(y); return [4 /*yield*/, y_1.next()]; case 1: - y_1_1 = _c.sent(); - _c.label = 2; + y_1_1 = _b.sent(); + _b.label = 2; case 2: if (!!y_1_1.done) return [3 /*break*/, 5]; x = y_1_1.value; - _c.label = 3; + _b.label = 3; case 3: return [4 /*yield*/, y_1.next()]; case 4: - y_1_1 = _c.sent(); + y_1_1 = _b.sent(); return [3 /*break*/, 2]; case 5: return [3 /*break*/, 12]; case 6: - _a = _c.sent(); + e_1_1 = _b.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 12]; case 7: - _c.trys.push([7, , 10, 11]); - if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; - return [4 /*yield*/, _b.call(y_1)]; + _b.trys.push([7, , 10, 11]); + if (!(y_1_1 && !y_1_1.done && (_a = y_1.return))) return [3 /*break*/, 9]; + return [4 /*yield*/, _a.call(y_1)]; case 8: - _c.sent(); - _c.label = 9; + _b.sent(); + _b.label = 9; case 9: return [3 /*break*/, 11]; case 10: if (e_1) throw e_1.error; @@ -239,36 +239,36 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar }; function f3() { return __asyncGenerator(this, arguments, function f3_1() { - var y, y_1, y_1_1, x, _a, e_1, _b; - return __generator(this, function (_c) { - switch (_c.label) { + var y, y_1, y_1_1, x, e_1_1, e_1, _a; + return __generator(this, function (_b) { + switch (_b.label) { case 0: - _c.trys.push([0, 6, 7, 12]); + _b.trys.push([0, 6, 7, 12]); y_1 = __asyncValues(y); return [4 /*yield*/, ["await", y_1.next()]]; case 1: - y_1_1 = _c.sent(); - _c.label = 2; + y_1_1 = _b.sent(); + _b.label = 2; case 2: if (!!y_1_1.done) return [3 /*break*/, 5]; x = y_1_1.value; - _c.label = 3; + _b.label = 3; case 3: return [4 /*yield*/, ["await", y_1.next()]]; case 4: - y_1_1 = _c.sent(); + y_1_1 = _b.sent(); return [3 /*break*/, 2]; case 5: return [3 /*break*/, 12]; case 6: - _a = _c.sent(); + e_1_1 = _b.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 12]; case 7: - _c.trys.push([7, , 10, 11]); - if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; - return [4 /*yield*/, ["await", _b.call(y_1)]]; + _b.trys.push([7, , 10, 11]); + if (!(y_1_1 && !y_1_1.done && (_a = y_1.return))) return [3 /*break*/, 9]; + return [4 /*yield*/, ["await", _a.call(y_1)]]; case 8: - _c.sent(); - _c.label = 9; + _b.sent(); + _b.label = 9; case 9: return [3 /*break*/, 11]; case 10: if (e_1) throw e_1.error; @@ -327,36 +327,36 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar }; function f4() { return __asyncGenerator(this, arguments, function f4_1() { - var x, y, y_1, y_1_1, _a, e_1, _b; - return __generator(this, function (_c) { - switch (_c.label) { + var x, y, y_1, y_1_1, e_1_1, e_1, _a; + return __generator(this, function (_b) { + switch (_b.label) { case 0: - _c.trys.push([0, 6, 7, 12]); + _b.trys.push([0, 6, 7, 12]); y_1 = __asyncValues(y); return [4 /*yield*/, ["await", y_1.next()]]; case 1: - y_1_1 = _c.sent(); - _c.label = 2; + y_1_1 = _b.sent(); + _b.label = 2; case 2: if (!!y_1_1.done) return [3 /*break*/, 5]; x = y_1_1.value; - _c.label = 3; + _b.label = 3; case 3: return [4 /*yield*/, ["await", y_1.next()]]; case 4: - y_1_1 = _c.sent(); + y_1_1 = _b.sent(); return [3 /*break*/, 2]; case 5: return [3 /*break*/, 12]; case 6: - _a = _c.sent(); + e_1_1 = _b.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 12]; case 7: - _c.trys.push([7, , 10, 11]); - if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; - return [4 /*yield*/, ["await", _b.call(y_1)]]; + _b.trys.push([7, , 10, 11]); + if (!(y_1_1 && !y_1_1.done && (_a = y_1.return))) return [3 /*break*/, 9]; + return [4 /*yield*/, ["await", _a.call(y_1)]]; case 8: - _c.sent(); - _c.label = 9; + _b.sent(); + _b.label = 9; case 9: return [3 /*break*/, 11]; case 10: if (e_1) throw e_1.error; From cc4a3a830f1bd789495766db53e55e35c7cc5fd3 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 27 Feb 2017 14:18:46 -0800 Subject: [PATCH 052/167] Add check for undefined declarations --- src/services/goToDefinition.ts | 4 ++-- tests/cases/fourslash/goToDefinition_untypedModule.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/goToDefinition_untypedModule.ts diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 0ac6c9f7812..2e35d92b96e 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -198,11 +198,11 @@ namespace ts.GoToDefinition { return false; } - function tryAddSignature(signatureDeclarations: Declaration[], selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { + function tryAddSignature(signatureDeclarations: Declaration[] | undefined, selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { const declarations: Declaration[] = []; let definition: Declaration | undefined; - for (const d of signatureDeclarations) { + if (signatureDeclarations) for (const d of signatureDeclarations) { if (selectConstructors ? d.kind === SyntaxKind.Constructor : isSignatureDeclaration(d)) { declarations.push(d); if ((d).body) definition = d; diff --git a/tests/cases/fourslash/goToDefinition_untypedModule.ts b/tests/cases/fourslash/goToDefinition_untypedModule.ts new file mode 100644 index 00000000000..b4571438434 --- /dev/null +++ b/tests/cases/fourslash/goToDefinition_untypedModule.ts @@ -0,0 +1,10 @@ +/// + +// @Filename: /node_modules/foo/index.js +////not read + +// @Filename: /a.ts +////import { f } from "foo"; +/////**/f(); + +verify.goToDefinition("", []); From b977b8cc45d9c5fee51334507b95124cc393ab3b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 27 Feb 2017 15:58:01 -0800 Subject: [PATCH 053/167] Respond to code review comments --- src/compiler/binder.ts | 5 +- src/compiler/checker.ts | 4 +- .../inferringClassMembersFromAssignments.js | 13 ++ ...ferringClassMembersFromAssignments.symbols | 120 +++++++++++------- ...inferringClassMembersFromAssignments.types | 28 ++++ .../inferringClassMembersFromAssignments.ts | 8 ++ 6 files changed, 123 insertions(+), 55 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 2fc7317884d..beba3224963 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2254,10 +2254,7 @@ namespace ts { // this.foo assignment in a JavaScript class // Bind this property to the containing class const containingClass = container.parent; - const symbol = hasModifier(container, ModifierFlags.Static) - ? declareSymbol(containingClass.symbol.exports, containingClass.symbol, node, SymbolFlags.Property, SymbolFlags.None) - : declareSymbol(containingClass.symbol.members, containingClass.symbol, node, SymbolFlags.Property, SymbolFlags.None); - + const symbol = declareSymbol(hasModifier(container, ModifierFlags.Static) ? containingClass.symbol.exports : containingClass.symbol.members, containingClass.symbol, node, SymbolFlags.Property, SymbolFlags.None); if (symbol) { // symbols declared through 'this' property assignements can be overwritten by subsequent method declarations (symbol as Symbol).isReplaceableByMethod = true; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 93973fe71a8..aa8d42dd3c1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3472,7 +3472,7 @@ namespace ts { return undefined; } - function getWidendedTypeFromJSSpecialPropetyDeclarations(symbol: Symbol) { + function getWidenedTypeFromJSSpecialPropetyDeclarations(symbol: Symbol) { const types: Type[] = []; let definedInConstructor = false; let definedInMethod = false; @@ -3663,7 +3663,7 @@ namespace ts { // * className.prototype.method = expr if (declaration.kind === SyntaxKind.BinaryExpression || declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { - type = getWidendedTypeFromJSSpecialPropetyDeclarations(symbol); + type = getWidenedTypeFromJSSpecialPropetyDeclarations(symbol); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.js b/tests/baselines/reference/inferringClassMembersFromAssignments.js index 6513a3b03a6..a7b9e4ff8f0 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.js +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.js @@ -10,6 +10,7 @@ class C { else { this.inConstructor = "string" } + this.inMultiple = 0; } method() { if (Math.random()) { @@ -18,6 +19,7 @@ class C { else { this.inMethod = "string" } + this.inMultiple = "string"; } get() { if (Math.random()) { @@ -26,6 +28,7 @@ class C { else { this.inGetter = "string" } + this.inMultiple = false; } set() { if (Math.random()) { @@ -73,6 +76,11 @@ var stringOrNumberOrUndefined = c.inMethod; var stringOrNumberOrUndefined = c.inGetter; var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrBoolean: string | number | boolean; + +var stringOrNumberOrBoolean = c.inMultiple; + + var stringOrNumberOrUndefined = C.inStaticMethod; var stringOrNumberOrUndefined = C.inStaticGetter; var stringOrNumberOrUndefined = C.inStaticSetter; @@ -87,6 +95,7 @@ var C = (function () { else { this.inConstructor = "string"; } + this.inMultiple = 0; } C.prototype.method = function () { if (Math.random()) { @@ -95,6 +104,7 @@ var C = (function () { else { this.inMethod = "string"; } + this.inMultiple = "string"; }; C.prototype.get = function () { if (Math.random()) { @@ -103,6 +113,7 @@ var C = (function () { else { this.inGetter = "string"; } + this.inMultiple = false; }; C.prototype.set = function () { if (Math.random()) { @@ -145,6 +156,8 @@ var stringOrNumberOrUndefined; var stringOrNumberOrUndefined = c.inMethod; var stringOrNumberOrUndefined = c.inGetter; var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrBoolean; +var stringOrNumberOrBoolean = c.inMultiple; var stringOrNumberOrUndefined = C.inStaticMethod; var stringOrNumberOrUndefined = C.inStaticGetter; var stringOrNumberOrUndefined = C.inStaticSetter; diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.symbols b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols index d96d4ff359f..9951339f8a8 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.symbols +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols @@ -20,9 +20,13 @@ class C { >this : Symbol(C, Decl(a.js, 0, 0)) >inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) } + this.inMultiple = 0; +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) } method() { ->method : Symbol(C.method, Decl(a.js, 9, 5)) +>method : Symbol(C.method, Decl(a.js, 10, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -30,19 +34,23 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inMethod = 0; ->this.inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) +>this.inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) +>inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) } else { this.inMethod = "string" ->this.inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) +>this.inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) +>inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) } + this.inMultiple = "string"; +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) } get() { ->get : Symbol(C.get, Decl(a.js, 17, 5)) +>get : Symbol(C.get, Decl(a.js, 19, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -50,19 +58,23 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inGetter = 0; ->this.inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) } else { this.inGetter = "string" ->this.inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) } + this.inMultiple = false; +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) } set() { ->set : Symbol(C.set, Decl(a.js, 25, 5)) +>set : Symbol(C.set, Decl(a.js, 28, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -70,19 +82,19 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inSetter = 0; ->this.inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) } else { this.inSetter = "string" ->this.inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) } } static method() { ->method : Symbol(C.method, Decl(a.js, 33, 5)) +>method : Symbol(C.method, Decl(a.js, 36, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -90,19 +102,19 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inStaticMethod = 0; ->this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) } else { this.inStaticMethod = "string" ->this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) } } static get() { ->get : Symbol(C.get, Decl(a.js, 41, 5)) +>get : Symbol(C.get, Decl(a.js, 44, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -110,19 +122,19 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inStaticGetter = 0; ->this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) } else { this.inStaticGetter = "string" ->this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) } } static set() { ->set : Symbol(C.set, Decl(a.js, 49, 5)) +>set : Symbol(C.set, Decl(a.js, 52, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -130,15 +142,15 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inStaticSetter = 0; ->this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) } else { this.inStaticSetter = "string" ->this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) } } } @@ -158,41 +170,51 @@ var stringOrNumber = c.inConstructor; >inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) var stringOrNumberOrUndefined: string | number | undefined; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) var stringOrNumberOrUndefined = c.inMethod; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) ->c.inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>c.inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) >c : Symbol(c, Decl(b.ts, 0, 3)) ->inMethod : Symbol(C.inMethod, Decl(a.js, 11, 28), Decl(a.js, 14, 14)) +>inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) var stringOrNumberOrUndefined = c.inGetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) ->c.inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>c.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) >c : Symbol(c, Decl(b.ts, 0, 3)) ->inGetter : Symbol(C.inGetter, Decl(a.js, 19, 28), Decl(a.js, 22, 14)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) var stringOrNumberOrUndefined = c.inSetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) ->c.inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>c.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) >c : Symbol(c, Decl(b.ts, 0, 3)) ->inSetter : Symbol(C.inSetter, Decl(a.js, 27, 28), Decl(a.js, 30, 14)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) + +var stringOrNumberOrBoolean: string | number | boolean; +>stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 11, 3), Decl(b.ts, 13, 3)) + +var stringOrNumberOrBoolean = c.inMultiple; +>stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 11, 3), Decl(b.ts, 13, 3)) +>c.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) + var stringOrNumberOrUndefined = C.inStaticMethod; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) ->C.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>C.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) >C : Symbol(C, Decl(a.js, 0, 0)) ->inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 35, 28), Decl(a.js, 38, 14)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) var stringOrNumberOrUndefined = C.inStaticGetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) ->C.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>C.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) >C : Symbol(C, Decl(a.js, 0, 0)) ->inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 43, 28), Decl(a.js, 46, 14)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) var stringOrNumberOrUndefined = C.inStaticSetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 11, 3), Decl(b.ts, 12, 3), Decl(b.ts, 13, 3)) ->C.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>C.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) >C : Symbol(C, Decl(a.js, 0, 0)) ->inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 51, 28), Decl(a.js, 54, 14)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.types b/tests/baselines/reference/inferringClassMembersFromAssignments.types index c1b30ae4519..547cc62ba32 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.types +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.types @@ -25,6 +25,12 @@ class C { >inConstructor : string | number >"string" : "string" } + this.inMultiple = 0; +>this.inMultiple = 0 : 0 +>this.inMultiple : string | number | boolean +>this : this +>inMultiple : string | number | boolean +>0 : 0 } method() { >method : () => void @@ -50,6 +56,12 @@ class C { >inMethod : string | number | undefined >"string" : "string" } + this.inMultiple = "string"; +>this.inMultiple = "string" : "string" +>this.inMultiple : string | number | boolean +>this : this +>inMultiple : string | number | boolean +>"string" : "string" } get() { >get : () => void @@ -75,6 +87,12 @@ class C { >inGetter : string | number | undefined >"string" : "string" } + this.inMultiple = false; +>this.inMultiple = false : false +>this.inMultiple : string | number | boolean +>this : this +>inMultiple : string | number | boolean +>false : false } set() { >set : () => void @@ -214,6 +232,16 @@ var stringOrNumberOrUndefined = c.inSetter; >c : C >inSetter : string | number | undefined +var stringOrNumberOrBoolean: string | number | boolean; +>stringOrNumberOrBoolean : string | number | boolean + +var stringOrNumberOrBoolean = c.inMultiple; +>stringOrNumberOrBoolean : string | number | boolean +>c.inMultiple : string | number | boolean +>c : C +>inMultiple : string | number | boolean + + var stringOrNumberOrUndefined = C.inStaticMethod; >stringOrNumberOrUndefined : string | number | undefined >C.inStaticMethod : string | number | undefined diff --git a/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts index dc63f09b3ab..d843e86b725 100644 --- a/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts +++ b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts @@ -11,6 +11,7 @@ class C { else { this.inConstructor = "string" } + this.inMultiple = 0; } method() { if (Math.random()) { @@ -19,6 +20,7 @@ class C { else { this.inMethod = "string" } + this.inMultiple = "string"; } get() { if (Math.random()) { @@ -27,6 +29,7 @@ class C { else { this.inGetter = "string" } + this.inMultiple = false; } set() { if (Math.random()) { @@ -74,6 +77,11 @@ var stringOrNumberOrUndefined = c.inMethod; var stringOrNumberOrUndefined = c.inGetter; var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrBoolean: string | number | boolean; + +var stringOrNumberOrBoolean = c.inMultiple; + + var stringOrNumberOrUndefined = C.inStaticMethod; var stringOrNumberOrUndefined = C.inStaticGetter; var stringOrNumberOrUndefined = C.inStaticSetter; From 2a3800965b13c036789a131477a60fc8fd74d622 Mon Sep 17 00:00:00 2001 From: DLehenbauer Date: Tue, 28 Feb 2017 07:31:01 -0800 Subject: [PATCH 054/167] Fix TypeError when JSDoc.tags is undefined (see #14362) --- src/compiler/utilities.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 66bf693d831..2ab2fc2fc23 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1554,7 +1554,10 @@ namespace ts { } } else { - result.push(...filter((doc as JSDoc).tags, tag => tag.kind === kind)); + const tags = (doc as JSDoc).tags; + if (tags) { + result.push(...filter(tags, tag => tag.kind === kind)); + } } } return result; From 7afee8c3ab486176e052997c314cf1788362823e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 28 Feb 2017 06:09:22 -0800 Subject: [PATCH 055/167] Fix formatting --- src/services/goToDefinition.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 2e35d92b96e..b732d8a1193 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -199,10 +199,14 @@ namespace ts.GoToDefinition { } function tryAddSignature(signatureDeclarations: Declaration[] | undefined, selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { + if (!signatureDeclarations) { + return false; + } + const declarations: Declaration[] = []; let definition: Declaration | undefined; - if (signatureDeclarations) for (const d of signatureDeclarations) { + for (const d of signatureDeclarations) { if (selectConstructors ? d.kind === SyntaxKind.Constructor : isSignatureDeclaration(d)) { declarations.push(d); if ((d).body) definition = d; From 993397b5ab291567f31bd437c81bc4c24a9d2a3d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Feb 2017 08:54:38 -0800 Subject: [PATCH 056/167] Introduce CheckMode enum and getContextualMapper() function --- src/compiler/checker.ts | 208 ++++++++++++++++++++-------------------- src/compiler/types.ts | 3 +- 2 files changed, 107 insertions(+), 104 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ff3a1079b18..6e47b7a9808 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -433,6 +433,12 @@ namespace ts { ResolvedReturnType } + const enum CheckMode { + Normal = 0, // Normal type checking + SkipContextSensitive = 1, // Skip context sensitive function expressions + Inferential = 2, // Inferential typing + } + const builtinGlobals = createMap(); builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); @@ -11543,7 +11549,7 @@ namespace ts { while (type) { const thisType = getThisTypeFromContextualType(type); if (thisType) { - return thisType; + return instantiateType(thisType, getContextualMapper(containingLiteral)); } if (literal.parent.kind !== SyntaxKind.PropertyAssignment) { break; @@ -11929,6 +11935,16 @@ namespace ts { return undefined; } + function getContextualMapper(node: Node) { + while (node) { + if (node.contextualMapper) { + return node.contextualMapper; + } + node = node.parent; + } + return identityMapper; + } + // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type: Type, node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature { @@ -12019,31 +12035,12 @@ namespace ts { return result; } - /** - * Detect if the mapper implies an inference context. Specifically, there are 4 possible values - * for a mapper. Let's go through each one of them: - * - * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, - * which could cause us to assign a parameter a type - * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in - * inferential typing (context is undefined for the identityMapper) - * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign - * types to parameters and fix type parameters (context is defined) - * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be - * passed as the contextual mapper when checking an expression (context is undefined for these) - * - * isInferentialContext is detecting if we are in case 3 - */ - function isInferentialContext(mapper: TypeMapper) { - return mapper && mapper.context; - } - - function checkSpreadExpression(node: SpreadElement, contextualMapper?: TypeMapper): Type { + function checkSpreadExpression(node: SpreadElement, checkMode?: CheckMode): Type { if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, ExternalEmitHelpers.SpreadIncludes); } - const arrayOrIterableType = checkExpression(node.expression, contextualMapper); + const arrayOrIterableType = checkExpression(node.expression, checkMode); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); } @@ -12052,7 +12049,7 @@ namespace ts { (node.kind === SyntaxKind.BinaryExpression && (node).operatorToken.kind === SyntaxKind.EqualsToken); } - function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type { + function checkArrayLiteral(node: ArrayLiteralExpression, checkMode?: CheckMode): Type { const elements = node.elements; let hasSpreadElement = false; const elementTypes: Type[] = []; @@ -12071,7 +12068,7 @@ namespace ts { // get the contextual element type from it. So we do something similar to // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. - const restArrayType = checkExpression((e).expression, contextualMapper); + const restArrayType = checkExpression((e).expression, checkMode); const restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || getIteratedTypeOrElementType(restArrayType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); if (restElementType) { @@ -12079,7 +12076,7 @@ namespace ts { } } else { - const type = checkExpressionForMutableLocation(e, contextualMapper); + const type = checkExpressionForMutableLocation(e, checkMode); elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElement; @@ -12194,7 +12191,7 @@ namespace ts { return createIndexInfo(unionType, /*isReadonly*/ false); } - function checkObjectLiteral(node: ObjectLiteralExpression, contextualMapper?: TypeMapper): Type { + function checkObjectLiteral(node: ObjectLiteralExpression, checkMode?: CheckMode): Type { const inDestructuringPattern = isAssignmentTarget(node); // Grammar checking checkGrammarObjectLiteralExpression(node, inDestructuringPattern); @@ -12221,14 +12218,14 @@ namespace ts { isObjectLiteralMethod(memberDecl)) { let type: Type; if (memberDecl.kind === SyntaxKind.PropertyAssignment) { - type = checkPropertyAssignment(memberDecl, contextualMapper); + type = checkPropertyAssignment(memberDecl, checkMode); } else if (memberDecl.kind === SyntaxKind.MethodDeclaration) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); + type = checkObjectLiteralMethod(memberDecl, checkMode); } else { Debug.assert(memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment); - type = checkExpressionForMutableLocation((memberDecl).name, contextualMapper); + type = checkExpressionForMutableLocation((memberDecl).name, checkMode); } typeFlags |= type.flags; @@ -12434,7 +12431,7 @@ namespace ts { * @remarks Because this function calls getSpreadType, it needs to use the same checks as checkObjectLiteral, * which also calls getSpreadType. */ - function createJsxAttributesTypeFromAttributesProperty(openingLikeElement: JsxOpeningLikeElement, filter?: (symbol: Symbol) => boolean, contextualMapper?: TypeMapper) { + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement: JsxOpeningLikeElement, filter?: (symbol: Symbol) => boolean, checkMode?: CheckMode) { const attributes = openingLikeElement.attributes; let attributesTable = createMap(); let spread: Type = emptyObjectType; @@ -12443,7 +12440,7 @@ namespace ts { const member = attributeDecl.symbol; if (isJsxAttribute(attributeDecl)) { const exprType = attributeDecl.initializer ? - checkExpression(attributeDecl.initializer, contextualMapper) : + checkExpression(attributeDecl.initializer, checkMode) : trueType; // is sugar for const attributeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); @@ -12514,8 +12511,8 @@ namespace ts { * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) * @param node a JSXAttributes to be resolved of its type */ - function checkJsxAttributes(node: JsxAttributes, contextualMapper?: TypeMapper) { - return createJsxAttributesTypeFromAttributesProperty(node.parent as JsxOpeningLikeElement, /*filter*/ undefined, contextualMapper); + function checkJsxAttributes(node: JsxAttributes, checkMode?: CheckMode) { + return createJsxAttributesTypeFromAttributesProperty(node.parent as JsxOpeningLikeElement, /*filter*/ undefined, checkMode); } function getJsxType(name: string) { @@ -13013,9 +13010,9 @@ namespace ts { } } - function checkJsxExpression(node: JsxExpression, contextualMapper?: TypeMapper) { + function checkJsxExpression(node: JsxExpression, checkMode?: CheckMode) { if (node.expression) { - const type = checkExpression(node.expression, contextualMapper); + const type = checkExpression(node.expression, checkMode); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -14877,9 +14874,9 @@ namespace ts { return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; } - function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { + function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper, checkMode: CheckMode) { const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - if (isInferentialContext(mapper)) { + if (checkMode === CheckMode.Inferential) { for (let i = 0; i < len; i++) { const declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -14893,21 +14890,21 @@ namespace ts { if (!parameter) { signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper, checkMode); } } for (let i = 0; i < len; i++) { const parameter = signature.parameters[i]; if (!(parameter.valueDeclaration).type) { const contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { const parameter = lastOrUndefined(signature.parameters); if (!(parameter.valueDeclaration).type) { const contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } } @@ -14927,7 +14924,7 @@ namespace ts { } } - function assignTypeToParameterAndFixTypeParameters(parameter: Symbol, contextualType: Type, mapper: TypeMapper) { + function assignTypeToParameterAndFixTypeParameters(parameter: Symbol, contextualType: Type, mapper: TypeMapper, checkMode: CheckMode) { const links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); @@ -14939,7 +14936,7 @@ namespace ts { } assignBindingElementTypes(parameter.valueDeclaration); } - else if (isInferentialContext(mapper)) { + else if (checkMode === CheckMode.Inferential) { // Even if the parameter already has a type, it might be because it was given a type while // processing the function as an argument to a prior signature during overload resolution. // If this was the case, it may have caused some type parameters to be fixed. So here, @@ -15007,7 +15004,7 @@ namespace ts { return promiseType; } - function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type { + function getReturnTypeFromBody(func: FunctionLikeDeclaration, checkMode?: CheckMode): Type { const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; @@ -15016,7 +15013,7 @@ namespace ts { const functionFlags = getFunctionFlags(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { - type = checkExpressionCached(func.body, contextualMapper); + type = checkExpressionCached(func.body, checkMode); if (functionFlags & FunctionFlags.Async) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -15028,7 +15025,7 @@ namespace ts { else { let types: Type[]; if (functionFlags & FunctionFlags.Generator) { // Generator or AsyncGenerator function - types = checkAndAggregateYieldOperandTypes(func, contextualMapper); + types = checkAndAggregateYieldOperandTypes(func, checkMode); if (types.length === 0) { const iterableIteratorAny = functionFlags & FunctionFlags.Async ? createAsyncIterableIteratorType(anyType) // AsyncGenerator function @@ -15041,7 +15038,7 @@ namespace ts { } } else { - types = checkAndAggregateReturnExpressionTypes(func, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. return functionFlags & FunctionFlags.Async @@ -15085,13 +15082,13 @@ namespace ts { : widenedType; // Generator function, AsyncGenerator function, or normal function } - function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, contextualMapper: TypeMapper): Type[] { + function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, checkMode: CheckMode): Type[] { const aggregatedTypes: Type[] = []; const functionFlags = getFunctionFlags(func); forEachYieldExpression(func.body, yieldExpression => { const expr = yieldExpression.expression; if (expr) { - let type = checkExpressionCached(expr, contextualMapper); + let type = checkExpressionCached(expr, checkMode); if (yieldExpression.asteriskToken) { // A yield* expression effectively yields everything that its operand yields type = checkIteratedTypeOrElementType(type, yieldExpression.expression, /*allowStringInput*/ false, (functionFlags & FunctionFlags.Async) !== 0); @@ -15131,7 +15128,7 @@ namespace ts { return true; } - function checkAndAggregateReturnExpressionTypes(func: FunctionLikeDeclaration, contextualMapper: TypeMapper): Type[] { + function checkAndAggregateReturnExpressionTypes(func: FunctionLikeDeclaration, checkMode: CheckMode): Type[] { const functionFlags = getFunctionFlags(func); const aggregatedTypes: Type[] = []; let hasReturnWithNoExpression = functionHasImplicitReturn(func); @@ -15139,7 +15136,7 @@ namespace ts { forEachReturnStatement(func.body, returnStatement => { const expr = returnStatement.expression; if (expr) { - let type = checkExpressionCached(expr, contextualMapper); + let type = checkExpressionCached(expr, checkMode); if (functionFlags & FunctionFlags.Async) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -15226,7 +15223,7 @@ namespace ts { } } - function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type { + function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, checkMode?: CheckMode): Type { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); // Grammar checking @@ -15236,7 +15233,7 @@ namespace ts { } // The identityMapper object is used to indicate that function expressions are wildcards - if (contextualMapper === identityMapper && isContextSensitive(node)) { + if (checkMode === CheckMode.SkipContextSensitive && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } @@ -15244,7 +15241,7 @@ namespace ts { const links = getNodeLinks(node); const type = getTypeOfSymbol(node.symbol); const contextSensitive = isContextSensitive(node); - const mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + const mightFixTypeParameters = contextSensitive && checkMode === CheckMode.Inferential; // Check if function expression is contextually typed and assign parameter types if so. // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to @@ -15260,10 +15257,10 @@ namespace ts { if (contextualSignature) { const signature = getSignaturesOfType(type, SignatureKind.Call)[0]; if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + assignContextualParameterTypes(signature, contextualSignature, getContextualMapper(node), checkMode); } if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - const returnType = getReturnTypeFromBody(node, contextualMapper); + const returnType = getReturnTypeFromBody(node, checkMode); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } @@ -15639,7 +15636,7 @@ namespace ts { } } - function checkArrayLiteralAssignment(node: ArrayLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type { + function checkArrayLiteralAssignment(node: ArrayLiteralExpression, sourceType: Type, checkMode?: CheckMode): Type { if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, ExternalEmitHelpers.Read); } @@ -15650,13 +15647,13 @@ namespace ts { const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; const elements = node.elements; for (let i = 0; i < elements.length; i++) { - checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, contextualMapper); + checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } return sourceType; } function checkArrayLiteralDestructuringElementAssignment(node: ArrayLiteralExpression, sourceType: Type, - elementIndex: number, elementType: Type, contextualMapper?: TypeMapper) { + elementIndex: number, elementType: Type, checkMode?: CheckMode) { const elements = node.elements; const element = elements[elementIndex]; if (element.kind !== SyntaxKind.OmittedExpression) { @@ -15668,7 +15665,7 @@ namespace ts { ? getTypeOfPropertyOfType(sourceType, propName) : elementType; if (type) { - return checkDestructuringAssignment(element, type, contextualMapper); + return checkDestructuringAssignment(element, type, checkMode); } else { // We still need to check element expression here because we may need to set appropriate flag on the expression @@ -15692,7 +15689,7 @@ namespace ts { error((restExpression).operatorToken, Diagnostics.A_rest_element_cannot_have_an_initializer); } else { - return checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); } } } @@ -15700,7 +15697,7 @@ namespace ts { return undefined; } - function checkDestructuringAssignment(exprOrAssignment: Expression | ShorthandPropertyAssignment, sourceType: Type, contextualMapper?: TypeMapper): Type { + function checkDestructuringAssignment(exprOrAssignment: Expression | ShorthandPropertyAssignment, sourceType: Type, checkMode?: CheckMode): Type { let target: Expression; if (exprOrAssignment.kind === SyntaxKind.ShorthandPropertyAssignment) { const prop = exprOrAssignment; @@ -15711,7 +15708,7 @@ namespace ts { !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & TypeFlags.Undefined)) { sourceType = getTypeWithFacts(sourceType, TypeFacts.NEUndefined); } - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } target = (exprOrAssignment).name; } @@ -15720,20 +15717,20 @@ namespace ts { } if (target.kind === SyntaxKind.BinaryExpression && (target).operatorToken.kind === SyntaxKind.EqualsToken) { - checkBinaryExpression(target, contextualMapper); + checkBinaryExpression(target, checkMode); target = (target).left; } if (target.kind === SyntaxKind.ObjectLiteralExpression) { return checkObjectLiteralAssignment(target, sourceType); } if (target.kind === SyntaxKind.ArrayLiteralExpression) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + return checkArrayLiteralAssignment(target, sourceType, checkMode); } - return checkReferenceAssignment(target, sourceType, contextualMapper); + return checkReferenceAssignment(target, sourceType, checkMode); } - function checkReferenceAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type { - const targetType = checkExpression(target, contextualMapper); + function checkReferenceAssignment(target: Expression, sourceType: Type, checkMode?: CheckMode): Type { + const targetType = checkExpression(target, checkMode); const error = target.parent.kind === SyntaxKind.SpreadAssignment ? Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; @@ -15821,17 +15818,17 @@ namespace ts { getUnionType([type1, type2], /*subtypeReduction*/ true); } - function checkBinaryExpression(node: BinaryExpression, contextualMapper?: TypeMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + function checkBinaryExpression(node: BinaryExpression, checkMode?: CheckMode) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } - function checkBinaryLikeExpression(left: Expression, operatorToken: Node, right: Expression, contextualMapper?: TypeMapper, errorNode?: Node) { + function checkBinaryLikeExpression(left: Expression, operatorToken: Node, right: Expression, checkMode?: CheckMode, errorNode?: Node) { const operator = operatorToken.kind; if (operator === SyntaxKind.EqualsToken && (left.kind === SyntaxKind.ObjectLiteralExpression || left.kind === SyntaxKind.ArrayLiteralExpression)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } - let leftType = checkExpression(left, contextualMapper); - let rightType = checkExpression(right, contextualMapper); + let leftType = checkExpression(left, checkMode); + let rightType = checkExpression(right, checkMode); switch (operator) { case SyntaxKind.AsteriskToken: case SyntaxKind.AsteriskAsteriskToken: @@ -16094,10 +16091,10 @@ namespace ts { return anyType; } - function checkConditionalExpression(node: ConditionalExpression, contextualMapper?: TypeMapper): Type { + function checkConditionalExpression(node: ConditionalExpression, checkMode?: CheckMode): Type { checkExpression(node.condition); - const type1 = checkExpression(node.whenTrue, contextualMapper); - const type2 = checkExpression(node.whenFalse, contextualMapper); + const type1 = checkExpression(node.whenTrue, checkMode); + const type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } @@ -16130,15 +16127,20 @@ namespace ts { return stringType; } - function checkExpressionWithContextualType(node: Expression, contextualType: Type, contextualMapper?: TypeMapper): Type { + function checkExpressionWithContextualType(node: Expression, contextualType: Type, contextualMapper: TypeMapper): Type { const saveContextualType = node.contextualType; + const saveContextualMapper = node.contextualMapper; node.contextualType = contextualType; - const result = checkExpression(node, contextualMapper); + node.contextualMapper = contextualMapper; + const checkMode = contextualMapper === identityMapper ? CheckMode.SkipContextSensitive : + contextualMapper ? CheckMode.Inferential : CheckMode.Normal; + const result = checkExpression(node, checkMode); node.contextualType = saveContextualType; + node.contextualMapper = saveContextualMapper; return result; } - function checkExpressionCached(node: Expression, contextualMapper?: TypeMapper): Type { + function checkExpressionCached(node: Expression, checkMode?: CheckMode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { // When computing a type that we're going to cache, we need to ignore any ongoing control flow @@ -16146,7 +16148,7 @@ namespace ts { // to the top of the stack ensures all transient types are computed from a known point. const saveFlowLoopStart = flowLoopStart; flowLoopStart = flowLoopCount; - links.resolvedType = checkExpression(node, contextualMapper); + links.resolvedType = checkExpression(node, checkMode); flowLoopStart = saveFlowLoopStart; } return links.resolvedType; @@ -16181,12 +16183,12 @@ namespace ts { return false; } - function checkExpressionForMutableLocation(node: Expression, contextualMapper?: TypeMapper): Type { - const type = checkExpression(node, contextualMapper); + function checkExpressionForMutableLocation(node: Expression, checkMode?: CheckMode): Type { + const type = checkExpression(node, checkMode); return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } - function checkPropertyAssignment(node: PropertyAssignment, contextualMapper?: TypeMapper): Type { + function checkPropertyAssignment(node: PropertyAssignment, checkMode?: CheckMode): Type { // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. @@ -16194,10 +16196,10 @@ namespace ts { checkComputedPropertyName(node.name); } - return checkExpressionForMutableLocation((node).initializer, contextualMapper); + return checkExpressionForMutableLocation((node).initializer, checkMode); } - function checkObjectLiteralMethod(node: MethodDeclaration, contextualMapper?: TypeMapper): Type { + function checkObjectLiteralMethod(node: MethodDeclaration, checkMode?: CheckMode): Type { // Grammar checking checkGrammarMethod(node); @@ -16208,19 +16210,19 @@ namespace ts { checkComputedPropertyName(node.name); } - const uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + const uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } - function instantiateTypeWithSingleGenericCallSignature(node: Expression | MethodDeclaration, type: Type, contextualMapper?: TypeMapper) { - if (isInferentialContext(contextualMapper)) { + function instantiateTypeWithSingleGenericCallSignature(node: Expression | MethodDeclaration, type: Type, checkMode?: CheckMode) { + if (checkMode === CheckMode.Inferential) { const signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { const contextualType = getApparentTypeOfContextualType(node); if (contextualType) { const contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, getContextualMapper(node))); } } } @@ -16254,14 +16256,14 @@ namespace ts { // object, it serves as an indicator that all contained function and arrow expressions should be considered to // have the wildcard function type; this form of type check is used during overload resolution to exclude // contextually typed function and arrow expressions in the initial phase. - function checkExpression(node: Expression | QualifiedName, contextualMapper?: TypeMapper): Type { + function checkExpression(node: Expression | QualifiedName, checkMode?: CheckMode): Type { let type: Type; if (node.kind === SyntaxKind.QualifiedName) { type = checkQualifiedName(node); } else { - const uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + const uninstantiatedType = checkExpressionWorker(node, checkMode); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { @@ -16281,7 +16283,7 @@ namespace ts { return type; } - function checkExpressionWorker(node: Expression, contextualMapper: TypeMapper): Type { + function checkExpressionWorker(node: Expression, checkMode: CheckMode): Type { switch (node.kind) { case SyntaxKind.Identifier: return checkIdentifier(node); @@ -16303,9 +16305,9 @@ namespace ts { case SyntaxKind.RegularExpressionLiteral: return globalRegExpType; case SyntaxKind.ArrayLiteralExpression: - return checkArrayLiteral(node, contextualMapper); + return checkArrayLiteral(node, checkMode); case SyntaxKind.ObjectLiteralExpression: - return checkObjectLiteral(node, contextualMapper); + return checkObjectLiteral(node, checkMode); case SyntaxKind.PropertyAccessExpression: return checkPropertyAccessExpression(node); case SyntaxKind.ElementAccessExpression: @@ -16316,12 +16318,12 @@ namespace ts { case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); case SyntaxKind.ParenthesizedExpression: - return checkExpression((node).expression, contextualMapper); + return checkExpression((node).expression, checkMode); case SyntaxKind.ClassExpression: return checkClassExpression(node); case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); case SyntaxKind.TypeOfExpression: return checkTypeOfExpression(node); case SyntaxKind.TypeAssertionExpression: @@ -16342,23 +16344,23 @@ namespace ts { case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); case SyntaxKind.BinaryExpression: - return checkBinaryExpression(node, contextualMapper); + return checkBinaryExpression(node, checkMode); case SyntaxKind.ConditionalExpression: - return checkConditionalExpression(node, contextualMapper); + return checkConditionalExpression(node, checkMode); case SyntaxKind.SpreadElement: - return checkSpreadExpression(node, contextualMapper); + return checkSpreadExpression(node, checkMode); case SyntaxKind.OmittedExpression: return undefinedWideningType; case SyntaxKind.YieldExpression: return checkYieldExpression(node); case SyntaxKind.JsxExpression: - return checkJsxExpression(node, contextualMapper); + return checkJsxExpression(node, checkMode); case SyntaxKind.JsxElement: return checkJsxElement(node); case SyntaxKind.JsxSelfClosingElement: return checkJsxSelfClosingElement(node); case SyntaxKind.JsxAttributes: - return checkJsxAttributes(node, contextualMapper); + return checkJsxAttributes(node, checkMode); case SyntaxKind.JsxOpeningElement: Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index de42d5d9745..d42be483755 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -522,6 +522,8 @@ /* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes) /* @internal */ flowNode?: FlowNode; // Associated FlowNode (initialized by binding) /* @internal */ emitNode?: EmitNode; // Associated EmitNode (initialized by transforms) + /* @internal */ contextualType?: Type; // Used to temporarily assign a contextual type during overload resolution + /* @internal */ contextualMapper?: TypeMapper; // Mapper for contextual type } export interface NodeArray extends Array, TextRange { @@ -960,7 +962,6 @@ export interface Expression extends Node { _expressionBrand: any; - contextualType?: Type; // Used to temporarily assign a contextual type during overload resolution } export interface OmittedExpression extends Expression { From ff2cfd2af5008e086470ac244442559a6febbb2e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Feb 2017 09:49:54 -0800 Subject: [PATCH 057/167] Update test --- .../thisType/thisTypeInObjectLiterals2.ts | 59 ++++++++++++++++++- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts index 7358b47259c..d476679aef1 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts @@ -1,4 +1,5 @@ // @declaration: true +// @strictNullChecks: true // @noImplicitAny: true // @noImplicitThis: true // @target: es5 @@ -34,15 +35,19 @@ let obj1 = { type Point = { x: number; y: number; - moveBy(dx: number, dy: number): void; + z?: number; + moveBy(dx: number, dy: number, dz?: number): void; } let p1: Point = { x: 10, y: 20, - moveBy(dx, dy) { + moveBy(dx, dy, dz) { this.x += dx; this.y += dy; + if (this.z && dz) { + this.z += dz; + } } }; @@ -51,9 +56,12 @@ declare function f1(p: Point): void; f1({ x: 10, y: 20, - moveBy(dx, dy) { + moveBy(dx, dy, dz) { this.x += dx; this.y += dy; + if (this.z && dz) { + this.z += dz; + } } }); @@ -97,6 +105,51 @@ let x2 = makeObject2({ } }); +// Check pattern similar to Object.defineProperty and Object.defineProperties + +type PropDesc = { + value?: T; + get?(): T; + set?(value: T): void; +} + +type PropDescMap = { + [K in keyof T]: PropDesc; +} + +declare function defineProp(obj: T, name: K, desc: PropDesc & ThisType): T & Record; + +declare function defineProps(obj: T, descs: PropDescMap & ThisType): T & U; + +let p10 = defineProp(p1, "foo", { value: 42 }); +p10.foo = p10.foo + 1; + +let p11 = defineProp(p1, "bar", { + get() { + return this.x; + }, + set(value: number) { + this.x = value; + } +}); +p11.bar = p11.bar + 1; + +let p12 = defineProps(p1, { + foo: { + value: 42 + }, + bar: { + get(): number { + return this.x; + }, + set(value: number) { + this.x = value; + } + } +}); +p12.foo = p12.foo + 1; +p12.bar = p12.bar + 1; + // Proof of concept for typing of Vue.js type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; From c87c124831856bd912d851a0505bd706e39022cb Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Feb 2017 09:50:02 -0800 Subject: [PATCH 058/167] Accept new baselines --- .../reference/thisTypeInObjectLiterals2.js | 113 +++- .../thisTypeInObjectLiterals2.symbols | 532 ++++++++++++------ .../reference/thisTypeInObjectLiterals2.types | 262 ++++++++- 3 files changed, 715 insertions(+), 192 deletions(-) diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.js b/tests/baselines/reference/thisTypeInObjectLiterals2.js index 08f02b6c5af..88cbd2555f6 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals2.js +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.js @@ -31,15 +31,19 @@ let obj1 = { type Point = { x: number; y: number; - moveBy(dx: number, dy: number): void; + z?: number; + moveBy(dx: number, dy: number, dz?: number): void; } let p1: Point = { x: 10, y: 20, - moveBy(dx, dy) { + moveBy(dx, dy, dz) { this.x += dx; this.y += dy; + if (this.z && dz) { + this.z += dz; + } } }; @@ -48,9 +52,12 @@ declare function f1(p: Point): void; f1({ x: 10, y: 20, - moveBy(dx, dy) { + moveBy(dx, dy, dz) { this.x += dx; this.y += dy; + if (this.z && dz) { + this.z += dz; + } } }); @@ -94,6 +101,51 @@ let x2 = makeObject2({ } }); +// Check pattern similar to Object.defineProperty and Object.defineProperties + +type PropDesc = { + value?: T; + get?(): T; + set?(value: T): void; +} + +type PropDescMap = { + [K in keyof T]: PropDesc; +} + +declare function defineProp(obj: T, name: K, desc: PropDesc & ThisType): T & Record; + +declare function defineProps(obj: T, descs: PropDescMap & ThisType): T & U; + +let p10 = defineProp(p1, "foo", { value: 42 }); +p10.foo = p10.foo + 1; + +let p11 = defineProp(p1, "bar", { + get() { + return this.x; + }, + set(value: number) { + this.x = value; + } +}); +p11.bar = p11.bar + 1; + +let p12 = defineProps(p1, { + foo: { + value: 42 + }, + bar: { + get(): number { + return this.x; + }, + set(value: number) { + this.x = value; + } + } +}); +p12.foo = p12.foo + 1; +p12.bar = p12.bar + 1; + // Proof of concept for typing of Vue.js type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; @@ -168,17 +220,23 @@ var obj1 = { var p1 = { x: 10, y: 20, - moveBy: function (dx, dy) { + moveBy: function (dx, dy, dz) { this.x += dx; this.y += dy; + if (this.z && dz) { + this.z += dz; + } } }; f1({ x: 10, y: 20, - moveBy: function (dx, dy) { + moveBy: function (dx, dy, dz) { this.x += dx; this.y += dy; + if (this.z && dz) { + this.z += dz; + } } }); var x1 = makeObject({ @@ -199,6 +257,32 @@ var x2 = makeObject2({ } } }); +var p10 = defineProp(p1, "foo", { value: 42 }); +p10.foo = p10.foo + 1; +var p11 = defineProp(p1, "bar", { + get: function () { + return this.x; + }, + set: function (value) { + this.x = value; + } +}); +p11.bar = p11.bar + 1; +var p12 = defineProps(p1, { + foo: { + value: 42 + }, + bar: { + get: function () { + return this.x; + }, + set: function (value) { + this.x = value; + } + } +}); +p12.foo = p12.foo + 1; +p12.bar = p12.bar + 1; var vue = new Vue({ data: function () { return ({ x: 1, y: 2 }); }, methods: { @@ -240,7 +324,8 @@ declare let obj1: { declare type Point = { x: number; y: number; - moveBy(dx: number, dy: number): void; + z?: number; + moveBy(dx: number, dy: number, dz?: number): void; }; declare let p1: Point; declare function f1(p: Point): void; @@ -266,6 +351,22 @@ declare let x2: { } & { moveBy(dx: number, dy: number): void; }; +declare type PropDesc = { + value?: T; + get?(): T; + set?(value: T): void; +}; +declare type PropDescMap = { + [K in keyof T]: PropDesc; +}; +declare function defineProp(obj: T, name: K, desc: PropDesc & ThisType): T & Record; +declare function defineProps(obj: T, descs: PropDescMap & ThisType): T & U; +declare let p10: Point & Record<"foo", number>; +declare let p11: Point & Record<"bar", number>; +declare let p12: Point & { + foo: number; + bar: number; +}; declare type Accessors = { [K in keyof T]: (() => T[K]) | Computed; }; diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.symbols b/tests/baselines/reference/thisTypeInObjectLiterals2.symbols index ef72c320cce..e7412ab487f 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals2.symbols +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.symbols @@ -75,71 +75,103 @@ type Point = { y: number; >y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) - moveBy(dx: number, dy: number): void; ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 32, 11)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 32, 22)) + z?: number; +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) + + moveBy(dx: number, dy: number, dz?: number): void; +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 32, 15)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 33, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 33, 22)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 33, 34)) } let p1: Point = { ->p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 35, 3)) +>p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) >Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) x: 10, ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 35, 17)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 36, 17)) y: 20, ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 36, 10)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 37, 10)) - moveBy(dx, dy) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 37, 10)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 38, 11)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 38, 14)) + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 38, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 39, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 39, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 39, 18)) this.x += dx; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 38, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 39, 11)) this.y += dy; >this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 38, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 39, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 39, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 39, 18)) + } } }; declare function f1(p: Point): void; ->f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 42, 2)) ->p : Symbol(p, Decl(thisTypeInObjectLiterals2.ts, 44, 20)) +>f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 46, 2)) +>p : Symbol(p, Decl(thisTypeInObjectLiterals2.ts, 48, 20)) >Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) f1({ ->f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 42, 2)) +>f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 46, 2)) x: 10, ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 46, 4)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 50, 4)) y: 20, ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 47, 10)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 51, 10)) - moveBy(dx, dy) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 48, 10)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 49, 11)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 49, 14)) + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 52, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 53, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 53, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 53, 18)) this.x += dx; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 49, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 53, 11)) this.y += dy; >this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 49, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 53, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 53, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 53, 18)) + } } }); @@ -147,59 +179,59 @@ f1({ // ThisType, 'this' is of type T. type ObjectDescriptor = { ->ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 53, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 58, 22)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 58, 24)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 65, 22)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 65, 24)) data?: D; ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 58, 31)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 58, 22)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 65, 31)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 65, 22)) methods?: M & ThisType; // Type of 'this' in methods is D & M ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 59, 13)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 58, 24)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 66, 13)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 65, 24)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 58, 22)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 58, 24)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 65, 22)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 65, 24)) } declare function makeObject(desc: ObjectDescriptor): D & M; ->makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 61, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 63, 28)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 63, 30)) ->desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 63, 34)) ->ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 53, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 63, 28)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 63, 30)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 63, 28)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 63, 30)) +>makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 68, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 70, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 70, 30)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 70, 34)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 70, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 70, 30)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 70, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 70, 30)) let x1 = makeObject({ ->x1 : Symbol(x1, Decl(thisTypeInObjectLiterals2.ts, 65, 3)) ->makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 61, 1)) +>x1 : Symbol(x1, Decl(thisTypeInObjectLiterals2.ts, 72, 3)) +>makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 68, 1)) data: { x: 0, y: 0 }, ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 65, 21)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 66, 11)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 66, 17)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 72, 21)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 73, 11)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 17)) methods: { ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 66, 25)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 73, 25)) moveBy(dx: number, dy: number) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 67, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 68, 15)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 68, 26)) +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 74, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 15)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 26)) this.x += dx; // Strongly typed this ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 66, 11)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 66, 11)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 68, 15)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 73, 11)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 73, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 15)) this.y += dy; // Strongly typed this ->this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 66, 17)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 66, 17)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 68, 26)) +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 17)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 17)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 26)) } } }); @@ -208,203 +240,367 @@ let x1 = makeObject({ // some ThisType, 'this' is of type T. type ObjectDescriptor2 = ThisType & { ->ObjectDescriptor2 : Symbol(ObjectDescriptor2, Decl(thisTypeInObjectLiterals2.ts, 73, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 78, 23)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 78, 25)) +>ObjectDescriptor2 : Symbol(ObjectDescriptor2, Decl(thisTypeInObjectLiterals2.ts, 80, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 85, 23)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 85, 25)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 78, 23)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 78, 25)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 85, 23)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 85, 25)) data?: D; ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 78, 50)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 78, 23)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 85, 50)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 85, 23)) methods?: M; ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 79, 13)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 78, 25)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 86, 13)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 85, 25)) } declare function makeObject2(desc: ObjectDescriptor): D & M; ->makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 81, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 83, 29)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 83, 31)) ->desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 83, 35)) ->ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 53, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 83, 29)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 83, 31)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 83, 29)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 83, 31)) +>makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 88, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 90, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 90, 31)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 90, 35)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 90, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 90, 31)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 90, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 90, 31)) let x2 = makeObject2({ ->x2 : Symbol(x2, Decl(thisTypeInObjectLiterals2.ts, 85, 3)) ->makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 81, 1)) +>x2 : Symbol(x2, Decl(thisTypeInObjectLiterals2.ts, 92, 3)) +>makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 88, 1)) data: { x: 0, y: 0 }, ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 85, 22)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 86, 11)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 86, 17)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 92, 22)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 93, 11)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 93, 17)) methods: { ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 86, 25)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 93, 25)) moveBy(dx: number, dy: number) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 87, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 88, 15)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 88, 26)) +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 94, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 95, 15)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 95, 26)) this.x += dx; // Strongly typed this ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 86, 11)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 86, 11)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 88, 15)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 93, 11)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 93, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 95, 15)) this.y += dy; // Strongly typed this ->this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 86, 17)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 86, 17)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 88, 26)) +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 93, 17)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 93, 17)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 95, 26)) } } }); +// Check pattern similar to Object.defineProperty and Object.defineProperties + +type PropDesc = { +>PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 100, 3)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) + + value?: T; +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 104, 20)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) + + get?(): T; +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 105, 14)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) + + set?(value: T): void; +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 106, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 107, 9)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) +} + +type PropDescMap = { +>PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 108, 1)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 110, 17)) + + [K in keyof T]: PropDesc; +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 111, 5)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 110, 17)) +>PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 100, 3)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 110, 17)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 111, 5)) +} + +declare function defineProp(obj: T, name: K, desc: PropDesc & ThisType): T & Record; +>defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 112, 1)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 114, 30)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 114, 48)) +>obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 114, 52)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) +>name : Symbol(name, Decl(thisTypeInObjectLiterals2.ts, 114, 59)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 114, 30)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 114, 68)) +>PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 100, 3)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 114, 48)) +>ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 114, 30)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 114, 48)) + +declare function defineProps(obj: T, descs: PropDescMap & ThisType): T & U; +>defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 114, 120)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 116, 31)) +>obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 116, 35)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) +>descs : Symbol(descs, Decl(thisTypeInObjectLiterals2.ts, 116, 42)) +>PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 108, 1)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 116, 31)) +>ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 116, 31)) + +let p10 = defineProp(p1, "foo", { value: 42 }); +>p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 118, 3)) +>defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 112, 1)) +>p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 118, 33)) + +p10.foo = p10.foo + 1; +>p10.foo : Symbol(foo) +>p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 118, 3)) +>foo : Symbol(foo) +>p10.foo : Symbol(foo) +>p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 118, 3)) +>foo : Symbol(foo) + +let p11 = defineProp(p1, "bar", { +>p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 121, 3)) +>defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 112, 1)) +>p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) + + get() { +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 121, 33)) + + return this.x; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) + + }, + set(value: number) { +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 124, 6)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 125, 8)) + + this.x = value; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 125, 8)) + } +}); +p11.bar = p11.bar + 1; +>p11.bar : Symbol(bar) +>p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 121, 3)) +>bar : Symbol(bar) +>p11.bar : Symbol(bar) +>p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 121, 3)) +>bar : Symbol(bar) + +let p12 = defineProps(p1, { +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) +>defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 114, 120)) +>p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) + + foo: { +>foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) + + value: 42 +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 132, 10)) + + }, + bar: { +>bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) + + get(): number { +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 135, 10)) + + return this.x; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) + + }, + set(value: number) { +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 138, 10)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 139, 12)) + + this.x = value; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 139, 12)) + } + } +}); +p12.foo = p12.foo + 1; +>p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) +>foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) +>p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) +>foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) + +p12.bar = p12.bar + 1; +>p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) +>bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) +>p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) +>bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) + // Proof of concept for typing of Vue.js type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; ->Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 93, 3)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 97, 15)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 97, 23)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 97, 15)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 97, 15)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 97, 23)) ->Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 99, 39)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 97, 15)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 97, 23)) +>Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 145, 22)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 149, 23)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 149, 23)) +>Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 151, 39)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 149, 23)) type Dictionary = { [x: string]: T } ->Dictionary : Symbol(Dictionary, Decl(thisTypeInObjectLiterals2.ts, 97, 70)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 99, 16)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 99, 24)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 99, 16)) +>Dictionary : Symbol(Dictionary, Decl(thisTypeInObjectLiterals2.ts, 149, 70)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 151, 16)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 151, 24)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 151, 16)) type Computed = { ->Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 99, 39)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 101, 14)) +>Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 151, 39)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 153, 14)) get?(): T; ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 101, 20)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 101, 14)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 153, 20)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 153, 14)) set?(value: T): void; ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 102, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 103, 9)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 101, 14)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 155, 9)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 153, 14)) } type VueOptions = ThisType & { ->VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 104, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 106, 16)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 106, 18)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 106, 21)) +>VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 156, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 158, 18)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 158, 21)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 106, 16)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 106, 18)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 106, 21)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 158, 18)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 158, 21)) data?: D | (() => D); ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 106, 50)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 106, 16)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 106, 16)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 158, 50)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) methods?: M; ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 107, 25)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 106, 18)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 159, 25)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 158, 18)) computed?: Accessors

; ->computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 108, 16)) ->Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 93, 3)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 106, 21)) +>computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 160, 16)) +>Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 145, 22)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 158, 21)) } declare const Vue: new (options: VueOptions) => D & M & P; ->Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 112, 13)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 112, 24)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 112, 26)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 112, 29)) ->options : Symbol(options, Decl(thisTypeInObjectLiterals2.ts, 112, 33)) ->VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 104, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 112, 24)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 112, 26)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 112, 29)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 112, 24)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 112, 26)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 112, 29)) +>Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 164, 13)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 164, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 164, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 164, 29)) +>options : Symbol(options, Decl(thisTypeInObjectLiterals2.ts, 164, 33)) +>VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 156, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 164, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 164, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 164, 29)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 164, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 164, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 164, 29)) let vue = new Vue({ ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) ->Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 112, 13)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) +>Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 164, 13)) data: () => ({ x: 1, y: 2 }), ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 114, 19)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 115, 24)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 166, 19)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 167, 24)) methods: { ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 115, 33)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 167, 33)) f(x: string) { ->f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 116, 14)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 117, 10)) +>f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 168, 14)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 169, 10)) return this.x; ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) } }, computed: { ->computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 120, 6)) +>computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 172, 6)) test(): number { ->test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 121, 15)) +>test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 173, 15)) return this.x; ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) }, hello: { ->hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 124, 10)) +>hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 176, 10)) get() { ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 125, 16)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 177, 16)) return "hi"; }, set(value: string) { ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 128, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 129, 16)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 180, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 181, 16)) } } } }); vue; ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) vue.x; ->vue.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 115, 18)) +>vue.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) vue.f("abc"); ->vue.f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 116, 14)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) ->f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 116, 14)) +>vue.f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 168, 14)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) +>f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 168, 14)) vue.test; ->vue.test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 121, 15)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) ->test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 121, 15)) +>vue.test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 173, 15)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) +>test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 173, 15)) vue.hello; ->vue.hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 124, 10)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 114, 3)) ->hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 124, 10)) +>vue.hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 176, 10)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) +>hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 176, 10)) diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.types b/tests/baselines/reference/thisTypeInObjectLiterals2.types index 39fd922f617..cc41be6b8c6 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals2.types +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.types @@ -81,16 +81,20 @@ type Point = { y: number; >y : number - moveBy(dx: number, dy: number): void; ->moveBy : (dx: number, dy: number) => void + z?: number; +>z : number | undefined + + moveBy(dx: number, dy: number, dz?: number): void; +>moveBy : (dx: number, dy: number, dz?: number | undefined) => void >dx : number >dy : number +>dz : number | undefined } let p1: Point = { >p1 : Point >Point : Point ->{ x: 10, y: 20, moveBy(dx, dy) { this.x += dx; this.y += dy; }} : { x: number; y: number; moveBy(dx: number, dy: number): void; } +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } x: 10, >x : number @@ -100,10 +104,11 @@ let p1: Point = { >y : number >20 : 20 - moveBy(dx, dy) { ->moveBy : (dx: number, dy: number) => void + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void >dx : number >dy : number +>dz : number | undefined this.x += dx; >this.x += dx : number @@ -118,6 +123,21 @@ let p1: Point = { >this : Point >y : number >dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } } }; @@ -127,9 +147,9 @@ declare function f1(p: Point): void; >Point : Point f1({ ->f1({ x: 10, y: 20, moveBy(dx, dy) { this.x += dx; this.y += dy; }}) : void +>f1({ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }}) : void >f1 : (p: Point) => void ->{ x: 10, y: 20, moveBy(dx, dy) { this.x += dx; this.y += dy; }} : { x: number; y: number; moveBy(dx: number, dy: number): void; } +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } x: 10, >x : number @@ -139,10 +159,11 @@ f1({ >y : number >20 : 20 - moveBy(dx, dy) { ->moveBy : (dx: number, dy: number) => void + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void >dx : number >dy : number +>dz : number | undefined this.x += dx; >this.x += dx : number @@ -157,6 +178,21 @@ f1({ >this : Point >y : number >dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } } }); @@ -169,11 +205,11 @@ type ObjectDescriptor = { >M : M data?: D; ->data : D +>data : D | undefined >D : D methods?: M & ThisType; // Type of 'this' in methods is D & M ->methods : M & ThisType +>methods : (M & ThisType) | undefined >M : M >ThisType : ThisType >D : D @@ -243,11 +279,11 @@ type ObjectDescriptor2 = ThisType & { >M : M data?: D; ->data : D +>data : D | undefined >D : D methods?: M; ->methods : M +>methods : M | undefined >M : M } @@ -302,6 +338,196 @@ let x2 = makeObject2({ } }); +// Check pattern similar to Object.defineProperty and Object.defineProperties + +type PropDesc = { +>PropDesc : PropDesc +>T : T + + value?: T; +>value : T | undefined +>T : T + + get?(): T; +>get : (() => T) | undefined +>T : T + + set?(value: T): void; +>set : ((value: T) => void) | undefined +>value : T +>T : T +} + +type PropDescMap = { +>PropDescMap : PropDescMap +>T : T + + [K in keyof T]: PropDesc; +>K : K +>T : T +>PropDesc : PropDesc +>T : T +>K : K +} + +declare function defineProp(obj: T, name: K, desc: PropDesc & ThisType): T & Record; +>defineProp : (obj: T, name: K, desc: PropDesc & ThisType) => T & Record +>T : T +>K : K +>U : U +>obj : T +>T : T +>name : K +>K : K +>desc : PropDesc & ThisType +>PropDesc : PropDesc +>U : U +>ThisType : ThisType +>T : T +>T : T +>Record : Record +>K : K +>U : U + +declare function defineProps(obj: T, descs: PropDescMap & ThisType): T & U; +>defineProps : (obj: T, descs: PropDescMap & ThisType) => T & U +>T : T +>U : U +>obj : T +>T : T +>descs : PropDescMap & ThisType +>PropDescMap : PropDescMap +>U : U +>ThisType : ThisType +>T : T +>T : T +>U : U + +let p10 = defineProp(p1, "foo", { value: 42 }); +>p10 : Point & Record<"foo", number> +>defineProp(p1, "foo", { value: 42 }) : Point & Record<"foo", number> +>defineProp : (obj: T, name: K, desc: PropDesc & ThisType) => T & Record +>p1 : Point +>"foo" : "foo" +>{ value: 42 } : { value: number; } +>value : number +>42 : 42 + +p10.foo = p10.foo + 1; +>p10.foo = p10.foo + 1 : number +>p10.foo : number +>p10 : Point & Record<"foo", number> +>foo : number +>p10.foo + 1 : number +>p10.foo : number +>p10 : Point & Record<"foo", number> +>foo : number +>1 : 1 + +let p11 = defineProp(p1, "bar", { +>p11 : Point & Record<"bar", number> +>defineProp(p1, "bar", { get() { return this.x; }, set(value: number) { this.x = value; }}) : Point & Record<"bar", number> +>defineProp : (obj: T, name: K, desc: PropDesc & ThisType) => T & Record +>p1 : Point +>"bar" : "bar" +>{ get() { return this.x; }, set(value: number) { this.x = value; }} : { get(): number; set(value: number): void; } + + get() { +>get : () => number + + return this.x; +>this.x : number +>this : Point +>x : number + + }, + set(value: number) { +>set : (value: number) => void +>value : number + + this.x = value; +>this.x = value : number +>this.x : number +>this : Point +>x : number +>value : number + } +}); +p11.bar = p11.bar + 1; +>p11.bar = p11.bar + 1 : number +>p11.bar : number +>p11 : Point & Record<"bar", number> +>bar : number +>p11.bar + 1 : number +>p11.bar : number +>p11 : Point & Record<"bar", number> +>bar : number +>1 : 1 + +let p12 = defineProps(p1, { +>p12 : Point & { foo: number; bar: number; } +>defineProps(p1, { foo: { value: 42 }, bar: { get(): number { return this.x; }, set(value: number) { this.x = value; } }}) : Point & { foo: number; bar: number; } +>defineProps : (obj: T, descs: PropDescMap & ThisType) => T & U +>p1 : Point +>{ foo: { value: 42 }, bar: { get(): number { return this.x; }, set(value: number) { this.x = value; } }} : { foo: { value: number; }; bar: { get(): number; set(value: number): void; }; } + + foo: { +>foo : { value: number; } +>{ value: 42 } : { value: number; } + + value: 42 +>value : number +>42 : 42 + + }, + bar: { +>bar : { get(): number; set(value: number): void; } +>{ get(): number { return this.x; }, set(value: number) { this.x = value; } } : { get(): number; set(value: number): void; } + + get(): number { +>get : () => number + + return this.x; +>this.x : number +>this : Point +>x : number + + }, + set(value: number) { +>set : (value: number) => void +>value : number + + this.x = value; +>this.x = value : number +>this.x : number +>this : Point +>x : number +>value : number + } + } +}); +p12.foo = p12.foo + 1; +>p12.foo = p12.foo + 1 : number +>p12.foo : number +>p12 : Point & { foo: number; bar: number; } +>foo : number +>p12.foo + 1 : number +>p12.foo : number +>p12 : Point & { foo: number; bar: number; } +>foo : number +>1 : 1 + +p12.bar = p12.bar + 1; +>p12.bar = p12.bar + 1 : number +>p12.bar : number +>p12 : Point & { foo: number; bar: number; } +>bar : number +>p12.bar + 1 : number +>p12.bar : number +>p12 : Point & { foo: number; bar: number; } +>bar : number +>1 : 1 + // Proof of concept for typing of Vue.js type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; @@ -326,11 +552,11 @@ type Computed = { >T : T get?(): T; ->get : () => T +>get : (() => T) | undefined >T : T set?(value: T): void; ->set : (value: T) => void +>set : ((value: T) => void) | undefined >value : T >T : T } @@ -346,16 +572,16 @@ type VueOptions = ThisType & { >P : P data?: D | (() => D); ->data : D | (() => D) +>data : D | (() => D) | undefined >D : D >D : D methods?: M; ->methods : M +>methods : M | undefined >M : M computed?: Accessors

; ->computed : Accessors

+>computed : Accessors

| undefined >Accessors : Accessors >P : P } From 4aac67b4e6ad0e690ce8c4deaf984ca1f74cca14 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 28 Feb 2017 09:59:17 -0800 Subject: [PATCH 059/167] Remove assertion --- src/compiler/checker.ts | 3 +-- src/compiler/diagnosticMessages.json | 2 +- .../reference/misspelledNewMetaProperty.errors.txt | 7 +++++++ tests/baselines/reference/misspelledNewMetaProperty.js | 5 +++++ tests/cases/compiler/misspelledNewMetaProperty.ts | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/misspelledNewMetaProperty.errors.txt create mode 100644 tests/baselines/reference/misspelledNewMetaProperty.js create mode 100644 tests/cases/compiler/misspelledNewMetaProperty.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 17e101fd286..48baef4494c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14804,7 +14804,6 @@ namespace ts { function checkMetaProperty(node: MetaProperty) { checkGrammarMetaProperty(node); - Debug.assert(node.keywordToken === SyntaxKind.NewKeyword && node.name.text === "target", "Unrecognized meta-property."); const container = getNewTargetContainer(node); if (!container) { error(node, Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); @@ -23021,7 +23020,7 @@ namespace ts { function checkGrammarMetaProperty(node: MetaProperty) { if (node.keywordToken === SyntaxKind.NewKeyword) { if (node.name.text !== "target") { - return grammarErrorOnNode(node.name, Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, tokenToString(node.keywordToken), "target"); + return grammarErrorOnNode(node.name, Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.text, tokenToString(node.keywordToken), "target"); } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b9572b2b0f4..75aa5d25f72 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3269,7 +3269,7 @@ "category": "Error", "code": 17011 }, - "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?": { + "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?": { "category": "Error", "code": 17012 }, diff --git a/tests/baselines/reference/misspelledNewMetaProperty.errors.txt b/tests/baselines/reference/misspelledNewMetaProperty.errors.txt new file mode 100644 index 00000000000..429a40a5b80 --- /dev/null +++ b/tests/baselines/reference/misspelledNewMetaProperty.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/misspelledNewMetaProperty.ts(1,20): error TS17012: 'targ' is not a valid meta-property for keyword 'new'. Did you mean 'target'? + + +==== tests/cases/compiler/misspelledNewMetaProperty.ts (1 errors) ==== + function foo(){new.targ} + ~~~~ +!!! error TS17012: 'targ' is not a valid meta-property for keyword 'new'. Did you mean 'target'? \ No newline at end of file diff --git a/tests/baselines/reference/misspelledNewMetaProperty.js b/tests/baselines/reference/misspelledNewMetaProperty.js new file mode 100644 index 00000000000..964cf91d52c --- /dev/null +++ b/tests/baselines/reference/misspelledNewMetaProperty.js @@ -0,0 +1,5 @@ +//// [misspelledNewMetaProperty.ts] +function foo(){new.targ} + +//// [misspelledNewMetaProperty.js] +function foo() { new.targ; } diff --git a/tests/cases/compiler/misspelledNewMetaProperty.ts b/tests/cases/compiler/misspelledNewMetaProperty.ts new file mode 100644 index 00000000000..8882264478c --- /dev/null +++ b/tests/cases/compiler/misspelledNewMetaProperty.ts @@ -0,0 +1 @@ +function foo(){new.targ} \ No newline at end of file From d6085f75c4f47a034c0fb1e6eb91d65655344c0a Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 28 Feb 2017 15:41:35 -0800 Subject: [PATCH 060/167] Return completions for JsDoc tagname even when there are no "@' sign prefix --- src/services/completions.ts | 38 ++++++++++++++++++++++++++++--------- src/services/jsDoc.ts | 33 ++++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index 1bf57d33fdc..4450be7cad6 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -16,11 +16,11 @@ namespace ts.Completions { return undefined; } - const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData; + const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName } = completionData; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getAllJsDocCompletionEntries() }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getAllJsDocCompletionEntries(shouldAppendAtSignBeforeJsDocTagName) }; } const entries: CompletionEntry[] = []; @@ -815,6 +815,12 @@ namespace ts.Completions { const isJavaScriptFile = isSourceFileJavaScript(sourceFile); let isJsDocTagName = false; + // This is for the case when users request completion in JsDoc without "@" + // i.e. + // /** + // * |completion here| + // **/ + let shouldAppendAtSignBeforeJsDocTagName = false; let start = timestamp(); const currentToken = getTokenAtPosition(sourceFile, position); @@ -826,10 +832,24 @@ namespace ts.Completions { log("getCompletionData: Is inside comment: " + (timestamp() - start)); if (insideComment) { - // The current position is next to the '@' sign, when no tag name being provided yet. - // Provide a full list of tag names - if (hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) { - isJsDocTagName = true; + if (hasDocComment(sourceFile, position)) { + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) { + isJsDocTagName = true; + } + else { + const lineStart = getLineStartPositionForPosition(position, sourceFile); + shouldAppendAtSignBeforeJsDocTagName = sourceFile.text.substr(lineStart, position).indexOf("@") === -1; + + // This is for the case + // /** + // * |completion here| + // **/ + if (shouldAppendAtSignBeforeJsDocTagName) { + isJsDocTagName = true; + } + } } // Completion should work inside certain JsDoc tags. For example: @@ -854,8 +874,8 @@ namespace ts.Completions { } } - if (isJsDocTagName) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName }; + if (isJsDocTagName || shouldAppendAtSignBeforeJsDocTagName) { + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName }; } if (!insideJsDocTagExpression) { @@ -983,7 +1003,7 @@ namespace ts.Completions { log("getCompletionData: Semantic work: " + (timestamp() - semanticStart)); - return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName }; + return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 08a51a63e63..40ee276b0fa 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -42,7 +42,8 @@ namespace ts.JsDoc { "prop", "version" ]; - let jsDocCompletionEntries: CompletionEntry[]; + let jsDocTagNameCompletionEntries: CompletionEntry[]; + let jsDocTagNameWithAtSignCompletionEntries: CompletionEntry[]; export function getJsDocCommentsFromDeclarations(declarations: Declaration[]) { // Only collect doc comments from duplicate declarations once: @@ -88,15 +89,27 @@ namespace ts.JsDoc { return undefined; } - export function getAllJsDocCompletionEntries(): CompletionEntry[] { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, tagName => { - return { - name: tagName, - kind: ScriptElementKind.keyword, - kindModifiers: "", - sortText: "0", - }; - })); + export function getAllJsDocCompletionEntries(shouldAppendAtSign: boolean): CompletionEntry[] { + if (!shouldAppendAtSign) { + return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, tagName => { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0", + }; + })); + } + else { + return jsDocTagNameWithAtSignCompletionEntries || (jsDocTagNameWithAtSignCompletionEntries = ts.map(jsDocTagNames, tagName => { + return { + name: `@${tagName}`, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + } + })); + } } /** From 441c5880d75fe40c9d3d0fba75bd6b541a0d8573 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 28 Feb 2017 15:41:47 -0800 Subject: [PATCH 061/167] Update fourslash tests --- tests/cases/fourslash/completionInJsDoc.ts | 53 +++++++++++++------ .../completionListAtInvalidLocations.ts | 44 +++++++-------- 2 files changed, 57 insertions(+), 40 deletions(-) diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts index 8ab9dbd0131..5eca52743a4 100644 --- a/tests/cases/fourslash/completionInJsDoc.ts +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -2,29 +2,39 @@ // @allowJs: true // @Filename: Foo.js -/////** @/*1*/ */ -////var v1; +//// /** @/*1*/ */ +//// var v1; //// -/////** @p/*2*/ */ -////var v2; +//// /** @p/*2*/ */ +//// var v2; //// -/////** @param /*3*/ */ -////var v3; +//// /** @param /*3*/ */ +//// var v3; //// -/////** @param { n/*4*/ } bar */ -////var v4; +//// /** @param { n/*4*/ } bar */ +//// var v4; //// -/////** @type { n/*5*/ } */ -////var v5; +//// /** @type { n/*5*/ } */ +//// var v5; //// -////// @/*6*/ -////var v6; +//// // @/*6*/ +//// var v6; //// -////// @pa/*7*/ -////var v7; +//// // @pa/*7*/ +//// var v7; //// -/////** @return { n/*8*/ } */ -////var v8; +//// /** @return { n/*8*/ } */ +//// var v8; +//// +//// /** /*9*/ */ +//// +//// /** +//// /*10*/ +//// */ +//// +//// /** +//// * /*11*/ +//// */ goTo.marker('1'); verify.completionListContains("constructor"); @@ -55,3 +65,14 @@ verify.completionListIsEmpty(); goTo.marker('8'); verify.completionListContains('number'); +goTo.marker('9'); +verify.completionListCount(40); +verify.completionListContains("@argument"); + +goTo.marker('10'); +verify.completionListCount(40); +verify.completionListContains("@return"); + +goTo.marker('11'); +verify.completionListCount(40); +verify.completionListContains("@argument"); diff --git a/tests/cases/fourslash/completionListAtInvalidLocations.ts b/tests/cases/fourslash/completionListAtInvalidLocations.ts index 0660f0e183b..171f63825f2 100644 --- a/tests/cases/fourslash/completionListAtInvalidLocations.ts +++ b/tests/cases/fourslash/completionListAtInvalidLocations.ts @@ -1,28 +1,24 @@ /// -////var v1 = ''; -////" /*openString1*/ -////var v2 = ''; -////"/*openString2*/ -////var v3 = ''; -////" bar./*openString3*/ -////var v4 = ''; -////// bar./*inComment1*/ -////var v6 = ''; -////// /*inComment2*/ -////var v7 = ''; -/////** /*inComment3*/ -////var v8 = ''; -/////** /*inComment4*/ **/ -////var v9 = ''; -/////* /*inComment5*/ -////var v11 = ''; -//// // /*inComment6*/ -////var v12 = ''; -////type htm/*inTypeAlias*/ -/// -////// /*inComment7*/ -////foo; -////var v10 = /reg/*inRegExp1*/ex/; +//// var v1 = ''; +//// " /*openString1*/ +//// var v2 = ''; +//// "/*openString2*/ +//// var v3 = ''; +//// " bar./*openString3*/ +//// var v4 = ''; +//// // bar./*inComment1*/ +//// var v6 = ''; +//// // /*inComment2*/ +//// var v7 = ''; +//// /* /*inComment3*/ +//// var v11 = ''; +//// // /*inComment4*/ +//// var v12 = ''; +//// type htm/*inTypeAlias*/ +//// +//// // /*inComment5*/ +//// foo; +//// var v10 = /reg/*inRegExp1*/ex/; goTo.eachMarker(() => verify.completionListIsEmpty()); From e74df1e38bbb911998defecb8899acf1a6806a12 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 28 Feb 2017 15:51:41 -0800 Subject: [PATCH 062/167] Remove unnecessary comment --- src/services/completions.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index 4450be7cad6..1d446f0aa59 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -842,10 +842,6 @@ namespace ts.Completions { const lineStart = getLineStartPositionForPosition(position, sourceFile); shouldAppendAtSignBeforeJsDocTagName = sourceFile.text.substr(lineStart, position).indexOf("@") === -1; - // This is for the case - // /** - // * |completion here| - // **/ if (shouldAppendAtSignBeforeJsDocTagName) { isJsDocTagName = true; } From 21c43009a667103d3818c6b3a03bcde1ca6654d6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Feb 2017 16:09:24 -0800 Subject: [PATCH 063/167] Enable new behavior only in --noImplicitThis mode --- src/compiler/checker.ts | 58 +++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a5c0f1819cb..6fb2e497a8d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11570,36 +11570,38 @@ namespace ts { } } } - const containingLiteral = getContainingObjectLiteral(func); - if (containingLiteral) { - // We have an object literal method. Check if the containing object literal has a contextual type - // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in - // any directly enclosing object literals. - const contextualType = getApparentTypeOfContextualType(containingLiteral); - let literal = containingLiteral; - let type = contextualType; - while (type) { - const thisType = getThisTypeFromContextualType(type); - if (thisType) { - return instantiateType(thisType, getContextualMapper(containingLiteral)); + if (compilerOptions.noImplicitThis) { + const containingLiteral = getContainingObjectLiteral(func); + if (containingLiteral) { + // We have an object literal method. Check if the containing object literal has a contextual type + // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in + // any directly enclosing object literals. + const contextualType = getApparentTypeOfContextualType(containingLiteral); + let literal = containingLiteral; + let type = contextualType; + while (type) { + const thisType = getThisTypeFromContextualType(type); + if (thisType) { + return instantiateType(thisType, getContextualMapper(containingLiteral)); + } + if (literal.parent.kind !== SyntaxKind.PropertyAssignment) { + break; + } + literal = literal.parent.parent; + type = getApparentTypeOfContextualType(literal); } - if (literal.parent.kind !== SyntaxKind.PropertyAssignment) { - break; - } - literal = literal.parent.parent; - type = getApparentTypeOfContextualType(literal); + // There was no contextual ThisType for the containing object literal, so the contextual type + // for 'this' is the contextual type for the containing object literal or the type of the object + // literal itself. + return contextualType || checkExpressionCached(containingLiteral); } - // There was no contextual ThisType for the containing object literal, so the contextual type - // for 'this' is the contextual type for the containing object literal or the type of the object - // literal itself. - return contextualType || checkExpressionCached(containingLiteral); - } - // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the - // contextual type for 'this' is 'obj'. - if (func.parent.kind === SyntaxKind.BinaryExpression && (func.parent).operatorToken.kind === SyntaxKind.EqualsToken) { - const target = (func.parent).left; - if (target.kind === SyntaxKind.PropertyAccessExpression || target.kind === SyntaxKind.ElementAccessExpression) { - return checkExpressionCached((target).expression); + // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the + // contextual type for 'this' is 'obj'. + if (func.parent.kind === SyntaxKind.BinaryExpression && (func.parent).operatorToken.kind === SyntaxKind.EqualsToken) { + const target = (func.parent).left; + if (target.kind === SyntaxKind.PropertyAccessExpression || target.kind === SyntaxKind.ElementAccessExpression) { + return checkExpressionCached((target).expression); + } } } return undefined; From 25738a8e411478896c65d983fa48840bb39db496 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Feb 2017 16:09:42 -0800 Subject: [PATCH 064/167] Update tests --- tests/cases/compiler/selfInLambdas.ts | 3 +++ tests/cases/compiler/thisBinding2.ts | 3 +++ .../conformance/types/thisType/looseThisTypeInFunctions.ts | 3 +++ tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts | 3 +++ .../conformance/types/thisType/thisTypeInObjectLiterals.ts | 3 +++ 5 files changed, 15 insertions(+) diff --git a/tests/cases/compiler/selfInLambdas.ts b/tests/cases/compiler/selfInLambdas.ts index 73eb5a5ce97..659b77fa458 100644 --- a/tests/cases/compiler/selfInLambdas.ts +++ b/tests/cases/compiler/selfInLambdas.ts @@ -1,3 +1,6 @@ +// @noImplicitAny: true +// @noImplicitThis: true + interface MouseEvent { x: number; y: number; diff --git a/tests/cases/compiler/thisBinding2.ts b/tests/cases/compiler/thisBinding2.ts index 5d330c9e908..b478ce9338f 100644 --- a/tests/cases/compiler/thisBinding2.ts +++ b/tests/cases/compiler/thisBinding2.ts @@ -1,3 +1,6 @@ +// @noImplicitAny: true +// @noImplicitThis: true + class C { x: number; constructor() { diff --git a/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts index b70f064f43a..0671fc78507 100644 --- a/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts @@ -1,3 +1,6 @@ +// @noImplicitAny: true +// @noImplicitThis: true + interface I { n: number; explicitThis(this: this, m: number): number; diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts index 1c80e21aa16..54dc9fa8a17 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts @@ -1,3 +1,6 @@ +// @noImplicitAny: true +// @noImplicitThis: true + interface IndexedWithThis { // this is a workaround for React init?: (this: this) => void; diff --git a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts index 599caf70f30..00550cdf25c 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts @@ -1,3 +1,6 @@ +// @noImplicitAny: true +// @noImplicitThis: true + let o = { d: "bar", m() { From f77cd8e54bcdeb6528e091740ddaaa20063f9544 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Feb 2017 16:11:05 -0800 Subject: [PATCH 065/167] Accept new baselines --- tests/baselines/reference/castTest.symbols | 6 -- tests/baselines/reference/castTest.types | 16 ++-- .../commentsOnObjectLiteral3.symbols | 7 -- .../reference/commentsOnObjectLiteral3.types | 26 ++--- ...declFileObjectLiteralWithAccessors.symbols | 3 - .../declFileObjectLiteralWithAccessors.types | 6 +- ...eclFileObjectLiteralWithOnlySetter.symbols | 3 - .../declFileObjectLiteralWithOnlySetter.types | 6 +- ...iationAssignmentWithIndexingOnLHS3.symbols | 7 -- ...ntiationAssignmentWithIndexingOnLHS3.types | 12 +-- .../reference/fatarrowfunctions.symbols | 5 - .../reference/fatarrowfunctions.types | 12 +-- .../fatarrowfunctionsInFunctions.symbols | 5 - .../fatarrowfunctionsInFunctions.types | 16 ++-- .../looseThisTypeInFunctions.errors.txt | 11 ++- .../reference/looseThisTypeInFunctions.js | 1 + .../baselines/reference/objectSpread.symbols | 3 - tests/baselines/reference/objectSpread.types | 12 +-- tests/baselines/reference/selfInLambdas.js | 1 + .../baselines/reference/selfInLambdas.symbols | 71 +++++++------- tests/baselines/reference/selfInLambdas.types | 1 + .../reference/thisBinding2.errors.txt | 28 ++++++ tests/baselines/reference/thisBinding2.js | 1 + .../reference/thisInObjectLiterals.errors.txt | 25 ----- .../reference/thisInObjectLiterals.symbols | 45 +++++++++ .../reference/thisInObjectLiterals.types | 50 ++++++++++ .../thisInPropertyBoundDeclarations.symbols | 2 - .../thisInPropertyBoundDeclarations.types | 12 +-- .../reference/thisTypeInFunctions2.errors.txt | 60 ++++++++++++ .../reference/thisTypeInFunctions2.js | 1 + .../reference/thisTypeInObjectLiterals.js | 1 + .../thisTypeInObjectLiterals.symbols | 95 ++++++++++--------- .../reference/thisTypeInObjectLiterals.types | 1 + .../throwInEnclosingStatements.symbols | 1 - .../throwInEnclosingStatements.types | 2 +- .../reference/underscoreTest1.symbols | 6 -- .../baselines/reference/underscoreTest1.types | 12 +-- 37 files changed, 346 insertions(+), 226 deletions(-) create mode 100644 tests/baselines/reference/thisBinding2.errors.txt delete mode 100644 tests/baselines/reference/thisInObjectLiterals.errors.txt create mode 100644 tests/baselines/reference/thisInObjectLiterals.symbols create mode 100644 tests/baselines/reference/thisInObjectLiterals.types create mode 100644 tests/baselines/reference/thisTypeInFunctions2.errors.txt diff --git a/tests/baselines/reference/castTest.symbols b/tests/baselines/reference/castTest.symbols index 0baee00ec47..944cc8238e6 100644 --- a/tests/baselines/reference/castTest.symbols +++ b/tests/baselines/reference/castTest.symbols @@ -71,13 +71,7 @@ var p_cast = ({ return new Point(this.x + dx, this.y + dy); >Point : Symbol(Point, Decl(castTest.ts, 11, 37)) ->this.x : Symbol(Point.x, Decl(castTest.ts, 14, 1)) ->this : Symbol(Point, Decl(castTest.ts, 11, 37)) ->x : Symbol(Point.x, Decl(castTest.ts, 14, 1)) >dx : Symbol(dx, Decl(castTest.ts, 25, 18)) ->this.y : Symbol(Point.y, Decl(castTest.ts, 15, 14)) ->this : Symbol(Point, Decl(castTest.ts, 11, 37)) ->y : Symbol(Point.y, Decl(castTest.ts, 15, 14)) >dy : Symbol(dy, Decl(castTest.ts, 25, 21)) }, diff --git a/tests/baselines/reference/castTest.types b/tests/baselines/reference/castTest.types index 08c9853dca6..666b2ccf78e 100644 --- a/tests/baselines/reference/castTest.types +++ b/tests/baselines/reference/castTest.types @@ -91,15 +91,15 @@ var p_cast = ({ return new Point(this.x + dx, this.y + dy); >new Point(this.x + dx, this.y + dy) : Point >Point : typeof Point ->this.x + dx : number ->this.x : number ->this : Point ->x : number +>this.x + dx : any +>this.x : any +>this : any +>x : any >dx : number ->this.y + dy : number ->this.y : number ->this : Point ->y : number +>this.y + dy : any +>this.y : any +>this : any +>y : any >dy : number }, diff --git a/tests/baselines/reference/commentsOnObjectLiteral3.symbols b/tests/baselines/reference/commentsOnObjectLiteral3.symbols index 34b4c706b42..3d58fe2d6d7 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral3.symbols +++ b/tests/baselines/reference/commentsOnObjectLiteral3.symbols @@ -21,10 +21,6 @@ var v = { >a : Symbol(a, Decl(commentsOnObjectLiteral3.ts, 8, 13), Decl(commentsOnObjectLiteral3.ts, 12, 18)) return this.prop; ->this.prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) ->this : Symbol(v, Decl(commentsOnObjectLiteral3.ts, 1, 7)) ->prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) - } /*trailing 1*/, //setter set a(value) { @@ -32,9 +28,6 @@ var v = { >value : Symbol(value, Decl(commentsOnObjectLiteral3.ts, 14, 7)) this.prop = value; ->this.prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) ->this : Symbol(v, Decl(commentsOnObjectLiteral3.ts, 1, 7)) ->prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) >value : Symbol(value, Decl(commentsOnObjectLiteral3.ts, 14, 7)) } // trailing 2 diff --git a/tests/baselines/reference/commentsOnObjectLiteral3.types b/tests/baselines/reference/commentsOnObjectLiteral3.types index b869e961401..4053e7e3f89 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral3.types +++ b/tests/baselines/reference/commentsOnObjectLiteral3.types @@ -1,8 +1,8 @@ === tests/cases/compiler/commentsOnObjectLiteral3.ts === var v = { ->v : { prop: number; func: () => void; func1(): void; a: number; } ->{ //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; } // trailing 2} : { prop: number; func: () => void; func1(): void; a: number; } +>v : { prop: number; func: () => void; func1(): void; a: any; } +>{ //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; } // trailing 2} : { prop: number; func: () => void; func1(): void; a: any; } //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, @@ -21,25 +21,25 @@ var v = { //getter get a() { ->a : number +>a : any return this.prop; ->this.prop : number ->this : { prop: number; func: () => void; func1(): void; a: number; } ->prop : number +>this.prop : any +>this : any +>prop : any } /*trailing 1*/, //setter set a(value) { ->a : number ->value : number +>a : any +>value : any this.prop = value; ->this.prop = value : number ->this.prop : number ->this : { prop: number; func: () => void; func1(): void; a: number; } ->prop : number ->value : number +>this.prop = value : any +>this.prop : any +>this : any +>prop : any +>value : any } // trailing 2 }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols b/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols index df94b262c74..862b0b3781e 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols @@ -15,9 +15,6 @@ function /*1*/makePoint(x: number) { set x(a: number) { this.b = a; } >x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30)) >a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14)) ->this.b : Symbol(b, Decl(declFileObjectLiteralWithAccessors.ts, 2, 12)) ->this : Symbol(__object, Decl(declFileObjectLiteralWithAccessors.ts, 2, 10)) ->b : Symbol(b, Decl(declFileObjectLiteralWithAccessors.ts, 2, 12)) >a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14)) }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.types b/tests/baselines/reference/declFileObjectLiteralWithAccessors.types index 1c36f321118..389b88de565 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.types +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.types @@ -19,9 +19,9 @@ function /*1*/makePoint(x: number) { >x : number >a : number >this.b = a : number ->this.b : number ->this : { b: number; x: number; } ->b : number +>this.b : any +>this : any +>b : any >a : number }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols index 9dd2461b871..f7474466140 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols @@ -11,9 +11,6 @@ function /*1*/makePoint(x: number) { set x(a: number) { this.b = a; } >x : Symbol(x, Decl(declFileObjectLiteralWithOnlySetter.ts, 3, 14)) >a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14)) ->this.b : Symbol(b, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 12)) ->this : Symbol(__object, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 10)) ->b : Symbol(b, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 12)) >a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14)) }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types index bf62561f57d..2f15818e0f2 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types @@ -15,9 +15,9 @@ function /*1*/makePoint(x: number) { >x : number >a : number >this.b = a : number ->this.b : number ->this : { b: number; x: number; } ->b : number +>this.b : any +>this : any +>b : any >a : number }; diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols index 785a5654681..dbd5aa150dc 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols @@ -8,18 +8,11 @@ var object = { get 0() { return this._0; ->this._0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) ->this : Symbol(object, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 12)) ->_0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) - }, set 0(x: number) { >x : Symbol(x, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 6, 10)) this._0 = x; ->this._0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) ->this : Symbol(object, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 12)) ->_0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) >x : Symbol(x, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 6, 10)) }, diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types index 77026be2795..32e5b33e411 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types @@ -10,9 +10,9 @@ var object = { get 0() { return this._0; ->this._0 : number ->this : { _0: number; 0: number; } ->_0 : number +>this._0 : any +>this : any +>_0 : any }, set 0(x: number) { @@ -20,9 +20,9 @@ var object = { this._0 = x; >this._0 = x : number ->this._0 : number ->this : { _0: number; 0: number; } ->_0 : number +>this._0 : any +>this : any +>_0 : any >x : number }, diff --git a/tests/baselines/reference/fatarrowfunctions.symbols b/tests/baselines/reference/fatarrowfunctions.symbols index 25213a9bbf8..6ed865b0914 100644 --- a/tests/baselines/reference/fatarrowfunctions.symbols +++ b/tests/baselines/reference/fatarrowfunctions.symbols @@ -163,11 +163,6 @@ var messenger = { setTimeout(() => { this.message.toString(); }, 3000); >setTimeout : Symbol(setTimeout, Decl(fatarrowfunctions.ts, 34, 1)) ->this.message.toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) ->this.message : Symbol(message, Decl(fatarrowfunctions.ts, 38, 17)) ->this : Symbol(messenger, Decl(fatarrowfunctions.ts, 38, 15)) ->message : Symbol(message, Decl(fatarrowfunctions.ts, 38, 17)) ->toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) } }; diff --git a/tests/baselines/reference/fatarrowfunctions.types b/tests/baselines/reference/fatarrowfunctions.types index 1114ae365cb..304c341c916 100644 --- a/tests/baselines/reference/fatarrowfunctions.types +++ b/tests/baselines/reference/fatarrowfunctions.types @@ -234,12 +234,12 @@ var messenger = { >setTimeout(() => { this.message.toString(); }, 3000) : number >setTimeout : (expression: any, msec?: number, language?: any) => number >() => { this.message.toString(); } : () => void ->this.message.toString() : string ->this.message.toString : () => string ->this.message : string ->this : { message: string; start: () => void; } ->message : string ->toString : () => string +>this.message.toString() : any +>this.message.toString : any +>this.message : any +>this : any +>message : any +>toString : any >3000 : 3000 } }; diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols b/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols index 977dd39460d..0a86affc215 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols +++ b/tests/baselines/reference/fatarrowfunctionsInFunctions.symbols @@ -16,17 +16,12 @@ var messenger = { var _self = this; >_self : Symbol(_self, Decl(fatarrowfunctionsInFunctions.ts, 5, 11)) ->this : Symbol(messenger, Decl(fatarrowfunctionsInFunctions.ts, 2, 15)) setTimeout(function() { >setTimeout : Symbol(setTimeout, Decl(fatarrowfunctionsInFunctions.ts, 0, 0)) _self.message.toString(); ->_self.message.toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) ->_self.message : Symbol(message, Decl(fatarrowfunctionsInFunctions.ts, 2, 17)) >_self : Symbol(_self, Decl(fatarrowfunctionsInFunctions.ts, 5, 11)) ->message : Symbol(message, Decl(fatarrowfunctionsInFunctions.ts, 2, 17)) ->toString : Symbol(String.toString, Decl(lib.d.ts, --, --)) }, 3000); } diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctions.types b/tests/baselines/reference/fatarrowfunctionsInFunctions.types index 88807f2a37b..8b9bd7ccd7a 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctions.types +++ b/tests/baselines/reference/fatarrowfunctionsInFunctions.types @@ -18,8 +18,8 @@ var messenger = { >function() { var _self = this; setTimeout(function() { _self.message.toString(); }, 3000); } : () => void var _self = this; ->_self : { message: string; start: () => void; } ->this : { message: string; start: () => void; } +>_self : any +>this : any setTimeout(function() { >setTimeout(function() { _self.message.toString(); }, 3000) : number @@ -27,12 +27,12 @@ var messenger = { >function() { _self.message.toString(); } : () => void _self.message.toString(); ->_self.message.toString() : string ->_self.message.toString : () => string ->_self.message : string ->_self : { message: string; start: () => void; } ->message : string ->toString : () => string +>_self.message.toString() : any +>_self.message.toString : any +>_self.message : any +>_self : any +>message : any +>toString : any }, 3000); >3000 : 3000 diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index 7e12a714406..cf4dcbd7dd5 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -1,13 +1,14 @@ -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(22,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. The 'this' types of each signature are incompatible. Type 'void' is not assignable to type 'C'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(25,27): error TS2339: Property 'length' does not exist on type 'number'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,28): error TS2339: Property 'length' does not exist on type 'number'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error TS2339: Property 'length' does not exist on type 'number'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(26,27): error TS2339: Property 'length' does not exist on type 'number'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(34,28): error TS2339: Property 'length' does not exist on type 'number'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(38,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(47,20): error TS2339: Property 'length' does not exist on type 'number'. ==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (5 errors) ==== + interface I { n: number; explicitThis(this: this, m: number): number; diff --git a/tests/baselines/reference/looseThisTypeInFunctions.js b/tests/baselines/reference/looseThisTypeInFunctions.js index cb1fbcc8b95..3e97691ade2 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.js +++ b/tests/baselines/reference/looseThisTypeInFunctions.js @@ -1,4 +1,5 @@ //// [looseThisTypeInFunctions.ts] + interface I { n: number; explicitThis(this: this, m: number): number; diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 0538121e90c..1ec2520e166 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -200,9 +200,6 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } } >plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) >c : Symbol(c, Decl(objectSpread.ts, 45, 3)) >plus : Symbol(plus, Decl(objectSpread.ts, 49, 48)) ->this.p : Symbol(p, Decl(objectSpread.ts, 49, 12)) ->this : Symbol(cplus, Decl(objectSpread.ts, 49, 10)) ->p : Symbol(p, Decl(objectSpread.ts, 49, 12)) cplus.plus(); >cplus.plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index 3a736721425..950dab43465 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -263,13 +263,13 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } } >cplus : { p: number; plus(): void; } >p : number >plus : () => void ->{ ...c, plus() { return this.p + 1; } } : { plus(): number; p: number; } +>{ ...c, plus() { return this.p + 1; } } : { plus(): any; p: number; } >c : C ->plus : () => number ->this.p + 1 : number ->this.p : number ->this : { p: number; plus(): void; } ->p : number +>plus : () => any +>this.p + 1 : any +>this.p : any +>this : any +>p : any >1 : 1 cplus.plus(); diff --git a/tests/baselines/reference/selfInLambdas.js b/tests/baselines/reference/selfInLambdas.js index b143c0c9e4e..f9654606716 100644 --- a/tests/baselines/reference/selfInLambdas.js +++ b/tests/baselines/reference/selfInLambdas.js @@ -1,4 +1,5 @@ //// [selfInLambdas.ts] + interface MouseEvent { x: number; y: number; diff --git a/tests/baselines/reference/selfInLambdas.symbols b/tests/baselines/reference/selfInLambdas.symbols index 0a51113710b..8efadb7c077 100644 --- a/tests/baselines/reference/selfInLambdas.symbols +++ b/tests/baselines/reference/selfInLambdas.symbols @@ -1,51 +1,52 @@ === tests/cases/compiler/selfInLambdas.ts === + interface MouseEvent { >MouseEvent : Symbol(MouseEvent, Decl(selfInLambdas.ts, 0, 0)) x: number; ->x : Symbol(MouseEvent.x, Decl(selfInLambdas.ts, 0, 22)) +>x : Symbol(MouseEvent.x, Decl(selfInLambdas.ts, 1, 22)) y: number; ->y : Symbol(MouseEvent.y, Decl(selfInLambdas.ts, 1, 14)) +>y : Symbol(MouseEvent.y, Decl(selfInLambdas.ts, 2, 14)) } declare var window: Window; ->window : Symbol(window, Decl(selfInLambdas.ts, 5, 11)) ->Window : Symbol(Window, Decl(selfInLambdas.ts, 5, 27)) +>window : Symbol(window, Decl(selfInLambdas.ts, 6, 11)) +>Window : Symbol(Window, Decl(selfInLambdas.ts, 6, 27)) interface Window { ->Window : Symbol(Window, Decl(selfInLambdas.ts, 5, 27)) +>Window : Symbol(Window, Decl(selfInLambdas.ts, 6, 27)) onmousemove: (ev: MouseEvent) => any; ->onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 6, 18)) ->ev : Symbol(ev, Decl(selfInLambdas.ts, 7, 18)) +>onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 7, 18)) +>ev : Symbol(ev, Decl(selfInLambdas.ts, 8, 18)) >MouseEvent : Symbol(MouseEvent, Decl(selfInLambdas.ts, 0, 0)) } var o = { ->o : Symbol(o, Decl(selfInLambdas.ts, 10, 3)) +>o : Symbol(o, Decl(selfInLambdas.ts, 11, 3)) counter: 0, ->counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) +>counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9)) start: function() { ->start : Symbol(start, Decl(selfInLambdas.ts, 12, 15)) +>start : Symbol(start, Decl(selfInLambdas.ts, 13, 15)) window.onmousemove = () => { ->window.onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 6, 18)) ->window : Symbol(window, Decl(selfInLambdas.ts, 5, 11)) ->onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 6, 18)) +>window.onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 7, 18)) +>window : Symbol(window, Decl(selfInLambdas.ts, 6, 11)) +>onmousemove : Symbol(Window.onmousemove, Decl(selfInLambdas.ts, 7, 18)) this.counter++ ->this.counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) ->this : Symbol(o, Decl(selfInLambdas.ts, 10, 7)) ->counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) +>this.counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9)) +>this : Symbol(o, Decl(selfInLambdas.ts, 11, 7)) +>counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9)) var f = () => this.counter; ->f : Symbol(f, Decl(selfInLambdas.ts, 18, 15)) ->this.counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) ->this : Symbol(o, Decl(selfInLambdas.ts, 10, 7)) ->counter : Symbol(counter, Decl(selfInLambdas.ts, 10, 9)) +>f : Symbol(f, Decl(selfInLambdas.ts, 19, 15)) +>this.counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9)) +>this : Symbol(o, Decl(selfInLambdas.ts, 11, 7)) +>counter : Symbol(counter, Decl(selfInLambdas.ts, 11, 9)) } @@ -56,39 +57,39 @@ var o = { class X { ->X : Symbol(X, Decl(selfInLambdas.ts, 24, 1)) +>X : Symbol(X, Decl(selfInLambdas.ts, 25, 1)) private value = "value"; ->value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9)) +>value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9)) public foo() { ->foo : Symbol(X.foo, Decl(selfInLambdas.ts, 29, 25)) +>foo : Symbol(X.foo, Decl(selfInLambdas.ts, 30, 25)) var outer= () => { ->outer : Symbol(outer, Decl(selfInLambdas.ts, 32, 5)) +>outer : Symbol(outer, Decl(selfInLambdas.ts, 33, 5)) var x = this.value; ->x : Symbol(x, Decl(selfInLambdas.ts, 33, 15)) ->this.value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9)) ->this : Symbol(X, Decl(selfInLambdas.ts, 24, 1)) ->value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9)) +>x : Symbol(x, Decl(selfInLambdas.ts, 34, 15)) +>this.value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9)) +>this : Symbol(X, Decl(selfInLambdas.ts, 25, 1)) +>value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9)) var inner = () => { ->inner : Symbol(inner, Decl(selfInLambdas.ts, 34, 15)) +>inner : Symbol(inner, Decl(selfInLambdas.ts, 35, 15)) var y = this.value; ->y : Symbol(y, Decl(selfInLambdas.ts, 35, 19)) ->this.value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9)) ->this : Symbol(X, Decl(selfInLambdas.ts, 24, 1)) ->value : Symbol(X.value, Decl(selfInLambdas.ts, 28, 9)) +>y : Symbol(y, Decl(selfInLambdas.ts, 36, 19)) +>this.value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9)) +>this : Symbol(X, Decl(selfInLambdas.ts, 25, 1)) +>value : Symbol(X.value, Decl(selfInLambdas.ts, 29, 9)) } inner(); ->inner : Symbol(inner, Decl(selfInLambdas.ts, 34, 15)) +>inner : Symbol(inner, Decl(selfInLambdas.ts, 35, 15)) }; outer(); ->outer : Symbol(outer, Decl(selfInLambdas.ts, 32, 5)) +>outer : Symbol(outer, Decl(selfInLambdas.ts, 33, 5)) } } diff --git a/tests/baselines/reference/selfInLambdas.types b/tests/baselines/reference/selfInLambdas.types index a26e1e0bf28..251cfb2d0c3 100644 --- a/tests/baselines/reference/selfInLambdas.types +++ b/tests/baselines/reference/selfInLambdas.types @@ -1,4 +1,5 @@ === tests/cases/compiler/selfInLambdas.ts === + interface MouseEvent { >MouseEvent : MouseEvent diff --git a/tests/baselines/reference/thisBinding2.errors.txt b/tests/baselines/reference/thisBinding2.errors.txt new file mode 100644 index 00000000000..ddfa078a2d2 --- /dev/null +++ b/tests/baselines/reference/thisBinding2.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/thisBinding2.ts(11,11): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + + +==== tests/cases/compiler/thisBinding2.ts (1 errors) ==== + + class C { + x: number; + constructor() { + this.x = (() => { + var x = 1; + return this.x; + })(); + this.x = function() { + var x = 1; + return this.x; + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }(); + } + } + declare function setTimeout(expression: any, msec?: number, language?: any): number; + var messenger = { + message: "Hello World", + start: function () { + return setTimeout(() => { var x = this.message; }, 3000); + } + }; + \ No newline at end of file diff --git a/tests/baselines/reference/thisBinding2.js b/tests/baselines/reference/thisBinding2.js index 142cd9db4a5..732cb4fac00 100644 --- a/tests/baselines/reference/thisBinding2.js +++ b/tests/baselines/reference/thisBinding2.js @@ -1,4 +1,5 @@ //// [thisBinding2.ts] + class C { x: number; constructor() { diff --git a/tests/baselines/reference/thisInObjectLiterals.errors.txt b/tests/baselines/reference/thisInObjectLiterals.errors.txt deleted file mode 100644 index 3da8430802d..00000000000 --- a/tests/baselines/reference/thisInObjectLiterals.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(15,21): error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'. - - -==== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts (1 errors) ==== - class MyClass { - t: number; - - fn() { - type ContainingThis = this; - //type of 'this' in an object literal is the containing scope's this - var t = { x: this, y: this.t }; - var t: { x: ContainingThis; y: number }; - } - } - - //type of 'this' in an object literal method is the type of the object literal - var obj = { - f() { - return this.spaaace; - ~~~~~~~ -!!! error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'. - } - }; - var obj: { f: () => any; }; - \ No newline at end of file diff --git a/tests/baselines/reference/thisInObjectLiterals.symbols b/tests/baselines/reference/thisInObjectLiterals.symbols new file mode 100644 index 00000000000..51f30009b65 --- /dev/null +++ b/tests/baselines/reference/thisInObjectLiterals.symbols @@ -0,0 +1,45 @@ +=== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts === +class MyClass { +>MyClass : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0)) + + t: number; +>t : Symbol(MyClass.t, Decl(thisInObjectLiterals.ts, 0, 15)) + + fn() { +>fn : Symbol(MyClass.fn, Decl(thisInObjectLiterals.ts, 1, 14)) + + type ContainingThis = this; +>ContainingThis : Symbol(ContainingThis, Decl(thisInObjectLiterals.ts, 3, 10)) + + //type of 'this' in an object literal is the containing scope's this + var t = { x: this, y: this.t }; +>t : Symbol(t, Decl(thisInObjectLiterals.ts, 6, 11), Decl(thisInObjectLiterals.ts, 7, 11)) +>x : Symbol(x, Decl(thisInObjectLiterals.ts, 6, 17)) +>this : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0)) +>y : Symbol(y, Decl(thisInObjectLiterals.ts, 6, 26)) +>this.t : Symbol(MyClass.t, Decl(thisInObjectLiterals.ts, 0, 15)) +>this : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0)) +>t : Symbol(MyClass.t, Decl(thisInObjectLiterals.ts, 0, 15)) + + var t: { x: ContainingThis; y: number }; +>t : Symbol(t, Decl(thisInObjectLiterals.ts, 6, 11), Decl(thisInObjectLiterals.ts, 7, 11)) +>x : Symbol(x, Decl(thisInObjectLiterals.ts, 7, 16)) +>ContainingThis : Symbol(ContainingThis, Decl(thisInObjectLiterals.ts, 3, 10)) +>y : Symbol(y, Decl(thisInObjectLiterals.ts, 7, 35)) + } +} + +//type of 'this' in an object literal method is the type of the object literal +var obj = { +>obj : Symbol(obj, Decl(thisInObjectLiterals.ts, 12, 3), Decl(thisInObjectLiterals.ts, 17, 3)) + + f() { +>f : Symbol(f, Decl(thisInObjectLiterals.ts, 12, 11)) + + return this.spaaace; + } +}; +var obj: { f: () => any; }; +>obj : Symbol(obj, Decl(thisInObjectLiterals.ts, 12, 3), Decl(thisInObjectLiterals.ts, 17, 3)) +>f : Symbol(f, Decl(thisInObjectLiterals.ts, 17, 10)) + diff --git a/tests/baselines/reference/thisInObjectLiterals.types b/tests/baselines/reference/thisInObjectLiterals.types new file mode 100644 index 00000000000..b707a473dfb --- /dev/null +++ b/tests/baselines/reference/thisInObjectLiterals.types @@ -0,0 +1,50 @@ +=== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts === +class MyClass { +>MyClass : MyClass + + t: number; +>t : number + + fn() { +>fn : () => void + + type ContainingThis = this; +>ContainingThis : this + + //type of 'this' in an object literal is the containing scope's this + var t = { x: this, y: this.t }; +>t : { x: this; y: number; } +>{ x: this, y: this.t } : { x: this; y: number; } +>x : this +>this : this +>y : number +>this.t : number +>this : this +>t : number + + var t: { x: ContainingThis; y: number }; +>t : { x: this; y: number; } +>x : this +>ContainingThis : this +>y : number + } +} + +//type of 'this' in an object literal method is the type of the object literal +var obj = { +>obj : { f(): any; } +>{ f() { return this.spaaace; }} : { f(): any; } + + f() { +>f : () => any + + return this.spaaace; +>this.spaaace : any +>this : any +>spaaace : any + } +}; +var obj: { f: () => any; }; +>obj : { f(): any; } +>f : () => any + diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols b/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols index 6afdd73f77f..12d3b2db31e 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols @@ -70,7 +70,6 @@ class A { a: function() { return this; }, >a : Symbol(a, Decl(thisInPropertyBoundDeclarations.ts, 33, 13)) ->this : Symbol(__object, Decl(thisInPropertyBoundDeclarations.ts, 33, 11)) }; @@ -80,7 +79,6 @@ class A { return { a: function() { return this; }, >a : Symbol(a, Decl(thisInPropertyBoundDeclarations.ts, 38, 16)) ->this : Symbol(__object, Decl(thisInPropertyBoundDeclarations.ts, 38, 14)) }; }; diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.types b/tests/baselines/reference/thisInPropertyBoundDeclarations.types index 7c2b28bfb3e..b783c5c1b5f 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.types +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.types @@ -84,9 +84,9 @@ class A { >{ a: function() { return this; }, } : { a: () => any; } a: function() { return this; }, ->a : () => { a: any; } ->function() { return this; } : () => { a: any; } ->this : { a: () => any; } +>a : () => any +>function() { return this; } : () => any +>this : any }; @@ -98,9 +98,9 @@ class A { >{ a: function() { return this; }, } : { a: () => any; } a: function() { return this; }, ->a : () => { a: any; } ->function() { return this; } : () => { a: any; } ->this : { a: () => any; } +>a : () => any +>function() { return this; } : () => any +>this : any }; }; diff --git a/tests/baselines/reference/thisTypeInFunctions2.errors.txt b/tests/baselines/reference/thisTypeInFunctions2.errors.txt new file mode 100644 index 00000000000..86721a76971 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions2.errors.txt @@ -0,0 +1,60 @@ +tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts(15,5): error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type. + + +==== tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts (1 errors) ==== + + interface IndexedWithThis { + // this is a workaround for React + init?: (this: this) => void; + willDestroy?: (this: any) => void; + [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); + } + interface IndexedWithoutThis { + // this is what React would like to write (and what they write today) + init?: () => void; + willDestroy?: () => void; + [propName: string]: any; + } + interface SimpleInterface { + foo(n: string); + ~~~~~~~~~~~~~~~ +!!! error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type. + bar(): number; + } + declare function extend1(args: IndexedWithThis): void; + declare function extend2(args: IndexedWithoutThis): void; + declare function simple(arg: SimpleInterface): void; + + extend1({ + init() { + this // this: IndexedWithThis because of contextual typing. + // this.mine + this.willDestroy + }, + mine: 12, + foo() { + this.url; // this: any because 'foo' matches the string indexer + this.willDestroy; + } + }); + extend2({ + init() { + this // this: containing object literal type + this.mine + }, + mine: 13, + foo() { + this // this: containing object literal type + this.mine + } + }); + + simple({ + foo(n) { + return n.length + this.bar(); + }, + bar() { + return 14; + } + }) + \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeInFunctions2.js b/tests/baselines/reference/thisTypeInFunctions2.js index 978f79483b0..7608629ea89 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.js +++ b/tests/baselines/reference/thisTypeInFunctions2.js @@ -1,4 +1,5 @@ //// [thisTypeInFunctions2.ts] + interface IndexedWithThis { // this is a workaround for React init?: (this: this) => void; diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.js b/tests/baselines/reference/thisTypeInObjectLiterals.js index 342c9d58c84..18f0a6407bc 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.js +++ b/tests/baselines/reference/thisTypeInObjectLiterals.js @@ -1,4 +1,5 @@ //// [thisTypeInObjectLiterals.ts] + let o = { d: "bar", m() { diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.symbols b/tests/baselines/reference/thisTypeInObjectLiterals.symbols index fd6d6ecebd5..374c790bd8f 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.symbols +++ b/tests/baselines/reference/thisTypeInObjectLiterals.symbols @@ -1,104 +1,105 @@ === tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts === + let o = { ->o : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 0, 3)) +>o : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 1, 3)) d: "bar", ->d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) +>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9)) m() { ->m : Symbol(m, Decl(thisTypeInObjectLiterals.ts, 1, 13)) +>m : Symbol(m, Decl(thisTypeInObjectLiterals.ts, 2, 13)) return this.d.length; >this.d.length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) ->this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 0, 7)) ->d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) +>this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9)) +>this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 1, 7)) +>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) }, f: function() { ->f : Symbol(f, Decl(thisTypeInObjectLiterals.ts, 4, 6)) +>f : Symbol(f, Decl(thisTypeInObjectLiterals.ts, 5, 6)) return this.d.length; >this.d.length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) ->this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 0, 7)) ->d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) +>this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9)) +>this : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 1, 7)) +>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 1, 9)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) } } let mutuallyRecursive = { ->mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 3)) +>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 3)) a: 100, ->a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25)) +>a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 11, 25)) start() { ->start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11)) +>start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 12, 11)) return this.passthrough(this.a); ->this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) ->this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23)) ->passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) ->this.a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25)) ->this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23)) ->a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25)) +>this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6)) +>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 23)) +>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6)) +>this.a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 11, 25)) +>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 23)) +>a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 11, 25)) }, passthrough(n: number) { ->passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 15, 16)) +>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 16, 16)) return this.sub1(n); ->this.sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6)) ->this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23)) ->sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 15, 16)) +>this.sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 18, 6)) +>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 23)) +>sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 18, 6)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 16, 16)) }, sub1(n: number): number { ->sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) +>sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 18, 6)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 19, 9)) if (n > 0) { ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 19, 9)) return this.passthrough(n - 1); ->this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) ->this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 23)) ->passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) +>this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6)) +>this : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 23)) +>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 15, 6)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 19, 9)) } return n; ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 19, 9)) } } var i: number = mutuallyRecursive.start(); ->i : Symbol(i, Decl(thisTypeInObjectLiterals.ts, 25, 3)) ->mutuallyRecursive.start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11)) ->mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 3)) ->start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11)) +>i : Symbol(i, Decl(thisTypeInObjectLiterals.ts, 26, 3)) +>mutuallyRecursive.start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 12, 11)) +>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 3)) +>start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 12, 11)) interface I { ->I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 25, 42)) +>I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 26, 42)) a: number; ->a : Symbol(I.a, Decl(thisTypeInObjectLiterals.ts, 26, 13)) +>a : Symbol(I.a, Decl(thisTypeInObjectLiterals.ts, 27, 13)) start(): number; ->start : Symbol(I.start, Decl(thisTypeInObjectLiterals.ts, 27, 14)) +>start : Symbol(I.start, Decl(thisTypeInObjectLiterals.ts, 28, 14)) passthrough(n: number): number; ->passthrough : Symbol(I.passthrough, Decl(thisTypeInObjectLiterals.ts, 28, 20)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 29, 16)) +>passthrough : Symbol(I.passthrough, Decl(thisTypeInObjectLiterals.ts, 29, 20)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 30, 16)) sub1(n: number): number; ->sub1 : Symbol(I.sub1, Decl(thisTypeInObjectLiterals.ts, 29, 35)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 30, 9)) +>sub1 : Symbol(I.sub1, Decl(thisTypeInObjectLiterals.ts, 30, 35)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 31, 9)) } var impl: I = mutuallyRecursive; ->impl : Symbol(impl, Decl(thisTypeInObjectLiterals.ts, 32, 3)) ->I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 25, 42)) ->mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 3)) +>impl : Symbol(impl, Decl(thisTypeInObjectLiterals.ts, 33, 3)) +>I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 26, 42)) +>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 11, 3)) diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.types b/tests/baselines/reference/thisTypeInObjectLiterals.types index d5c6d851faf..d4e6188b9cf 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.types +++ b/tests/baselines/reference/thisTypeInObjectLiterals.types @@ -1,4 +1,5 @@ === tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts === + let o = { >o : { d: string; m(): number; f: () => number; } >{ d: "bar", m() { return this.d.length; }, f: function() { return this.d.length; }} : { d: string; m(): number; f: () => number; } diff --git a/tests/baselines/reference/throwInEnclosingStatements.symbols b/tests/baselines/reference/throwInEnclosingStatements.symbols index 36dcd3cfcbd..63ed9dde578 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.symbols +++ b/tests/baselines/reference/throwInEnclosingStatements.symbols @@ -89,7 +89,6 @@ var aa = { >biz : Symbol(biz, Decl(throwInEnclosingStatements.ts, 41, 10)) throw this; ->this : Symbol(aa, Decl(throwInEnclosingStatements.ts, 40, 8)) } } diff --git a/tests/baselines/reference/throwInEnclosingStatements.types b/tests/baselines/reference/throwInEnclosingStatements.types index d859bbd6392..2d99ac435ae 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.types +++ b/tests/baselines/reference/throwInEnclosingStatements.types @@ -104,7 +104,7 @@ var aa = { >biz : () => void throw this; ->this : { id: number; biz(): void; } +>this : any } } diff --git a/tests/baselines/reference/underscoreTest1.symbols b/tests/baselines/reference/underscoreTest1.symbols index 3b578be8165..41b0c811027 100644 --- a/tests/baselines/reference/underscoreTest1.symbols +++ b/tests/baselines/reference/underscoreTest1.symbols @@ -395,16 +395,10 @@ var buttonView = { onClick: function () { alert('clicked: ' + this.label); }, >onClick : Symbol(onClick, Decl(underscoreTest1_underscoreTests.ts, 97, 24)) >alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14)) ->this.label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) ->this : Symbol(buttonView, Decl(underscoreTest1_underscoreTests.ts, 96, 16)) ->label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) onHover: function () { alert('hovering: ' + this.label); } >onHover : Symbol(onHover, Decl(underscoreTest1_underscoreTests.ts, 98, 62)) >alert : Symbol(alert, Decl(underscoreTest1_underscoreTests.ts, 2, 14)) ->this.label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) ->this : Symbol(buttonView, Decl(underscoreTest1_underscoreTests.ts, 96, 16)) ->label : Symbol(label, Decl(underscoreTest1_underscoreTests.ts, 96, 18)) }; _.bindAll(buttonView); diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 26e30ae6f52..afcc807b756 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -827,9 +827,9 @@ var buttonView = { >alert : (x: string) => void >'clicked: ' + this.label : string >'clicked: ' : "clicked: " ->this.label : string ->this : { label: string; onClick: () => void; onHover: () => void; } ->label : string +>this.label : any +>this : any +>label : any onHover: function () { alert('hovering: ' + this.label); } >onHover : () => void @@ -838,9 +838,9 @@ var buttonView = { >alert : (x: string) => void >'hovering: ' + this.label : string >'hovering: ' : "hovering: " ->this.label : string ->this : { label: string; onClick: () => void; onHover: () => void; } ->label : string +>this.label : any +>this : any +>label : any }; _.bindAll(buttonView); From a5d104c841fcf546e06df04edc021dbe7b93f032 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 17 Feb 2017 16:47:51 -0800 Subject: [PATCH 066/167] Fix #14136: Make `Object.create` return `any` all the time --- src/lib/es5.d.ts | 2 +- ...signingFromObjectToAnythingElse.errors.txt | 18 ++---- tests/baselines/reference/objectCreate.types | 60 +++++++++---------- tests/baselines/reference/objectCreate2.types | 56 ++++++++--------- 4 files changed, 65 insertions(+), 71 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 8f29deb67db..262c2ba21fe 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -140,7 +140,7 @@ interface ObjectConstructor { * Creates an object that has the specified prototype or that has null prototype. * @param o Object to use as a prototype. May be null. */ - create(o: T | null): T | object; + create(o: object | null): any; /** * Creates an object that has the specified prototype, and that optionally contains specified properties. diff --git a/tests/baselines/reference/assigningFromObjectToAnythingElse.errors.txt b/tests/baselines/reference/assigningFromObjectToAnythingElse.errors.txt index 070339e4726..d3395c7ebc9 100644 --- a/tests/baselines/reference/assigningFromObjectToAnythingElse.errors.txt +++ b/tests/baselines/reference/assigningFromObjectToAnythingElse.errors.txt @@ -1,11 +1,8 @@ tests/cases/compiler/assigningFromObjectToAnythingElse.ts(3,1): error TS2322: Type 'Object' is not assignable to type 'RegExp'. The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? Property 'exec' is missing in type 'Object'. -tests/cases/compiler/assigningFromObjectToAnythingElse.ts(5,5): error TS2322: Type 'object | Object' is not assignable to type 'String'. - Type 'object' is not assignable to type 'String'. - Property 'charAt' is missing in type '{}'. -tests/cases/compiler/assigningFromObjectToAnythingElse.ts(6,5): error TS2322: Type 'object | Number' is not assignable to type 'String'. - Type 'object' is not assignable to type 'String'. +tests/cases/compiler/assigningFromObjectToAnythingElse.ts(5,17): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/assigningFromObjectToAnythingElse.ts(6,17): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/assigningFromObjectToAnythingElse.ts(8,5): error TS2322: Type 'Object' is not assignable to type 'Error'. The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? Property 'name' is missing in type 'Object'. @@ -21,14 +18,11 @@ tests/cases/compiler/assigningFromObjectToAnythingElse.ts(8,5): error TS2322: Ty !!! error TS2322: Property 'exec' is missing in type 'Object'. var a: String = Object.create(""); - ~ -!!! error TS2322: Type 'object | Object' is not assignable to type 'String'. -!!! error TS2322: Type 'object' is not assignable to type 'String'. -!!! error TS2322: Property 'charAt' is missing in type '{}'. + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var c: String = Object.create(1); - ~ -!!! error TS2322: Type 'object | Number' is not assignable to type 'String'. -!!! error TS2322: Type 'object' is not assignable to type 'String'. + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var w: Error = new Object(); ~ diff --git a/tests/baselines/reference/objectCreate.types b/tests/baselines/reference/objectCreate.types index 028c98af817..b4e0e72061e 100644 --- a/tests/baselines/reference/objectCreate.types +++ b/tests/baselines/reference/objectCreate.types @@ -7,19 +7,19 @@ declare var union: null | { a: number, b: string }; >b : string var n = Object.create(null); // object ->n : object ->Object.create(null) : object ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>n : any +>Object.create(null) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >null : null var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } ->t : object | { a: number; b: string; } ->Object.create({ a: 1, b: "" }) : object | { a: number; b: string; } ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>t : any +>Object.create({ a: 1, b: "" }) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >{ a: 1, b: "" } : { a: number; b: string; } >a : number >1 : 1 @@ -27,45 +27,45 @@ var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } >"" : "" var u = Object.create(union); // object | {a: number, b: string } ->u : object | { a: number; b: string; } ->Object.create(union) : object | { a: number; b: string; } ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>u : any +>Object.create(union) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >union : { a: number; b: string; } | null var e = Object.create({}); // {} ->e : object | {} ->Object.create({}) : object | {} ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>e : any +>Object.create({}) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >{} : {} var o = Object.create({}); // object ->o : object ->Object.create({}) : object ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>o : any +>Object.create({}) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >{} : object >{} : {} var a = Object.create(null, {}); // any >a : any >Object.create(null, {}) : any ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >null : null >{} : {} var a = Object.create({ a: 1, b: "" }, {}); >a : any >Object.create({ a: 1, b: "" }, {}) : any ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >{ a: 1, b: "" } : { a: number; b: string; } >a : number >1 : 1 @@ -76,27 +76,27 @@ var a = Object.create({ a: 1, b: "" }, {}); var a = Object.create(union, {}); >a : any >Object.create(union, {}) : any ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >union : { a: number; b: string; } | null >{} : {} var a = Object.create({}, {}); >a : any >Object.create({}, {}) : any ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >{} : {} >{} : {} var a = Object.create({}, {}); >a : any >Object.create({}, {}) : any ->Object.create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T | null): object | T; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } >{} : object >{} : {} >{} : {} diff --git a/tests/baselines/reference/objectCreate2.types b/tests/baselines/reference/objectCreate2.types index 1b33723b0c9..3e19c08bfc0 100644 --- a/tests/baselines/reference/objectCreate2.types +++ b/tests/baselines/reference/objectCreate2.types @@ -9,17 +9,17 @@ declare var union: null | { a: number, b: string }; var n = Object.create(null); // any >n : any >Object.create(null) : any ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >null : null var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } ->t : object | { a: number; b: string; } ->Object.create({ a: 1, b: "" }) : object | { a: number; b: string; } ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>t : any +>Object.create({ a: 1, b: "" }) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >{ a: 1, b: "" } : { a: number; b: string; } >a : number >1 : 1 @@ -27,45 +27,45 @@ var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } >"" : "" var u = Object.create(union); // {a: number, b: string } ->u : object | { a: number; b: string; } ->Object.create(union) : object | { a: number; b: string; } ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>u : any +>Object.create(union) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >union : { a: number; b: string; } var e = Object.create({}); // {} ->e : object | {} ->Object.create({}) : object | {} ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>e : any +>Object.create({}) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >{} : {} var o = Object.create({}); // object ->o : object ->Object.create({}) : object ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>o : any +>Object.create({}) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >{} : object >{} : {} var a = Object.create(null, {}); // any >a : any >Object.create(null, {}) : any ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >null : null >{} : {} var a = Object.create({ a: 1, b: "" }, {}); >a : any >Object.create({ a: 1, b: "" }, {}) : any ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >{ a: 1, b: "" } : { a: number; b: string; } >a : number >1 : 1 @@ -76,27 +76,27 @@ var a = Object.create({ a: 1, b: "" }, {}); var a = Object.create(union, {}); >a : any >Object.create(union, {}) : any ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >union : { a: number; b: string; } >{} : {} var a = Object.create({}, {}); >a : any >Object.create({}, {}) : any ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >{} : {} >{} : {} var a = Object.create({}, {}); >a : any >Object.create({}, {}) : any ->Object.create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >Object : ObjectConstructor ->create : { (o: T): object | T; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } >{} : object >{} : {} >{} : {} From a4904935e0b2be0f7f49bc0de89921884b223614 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 17 Feb 2017 18:01:13 -0800 Subject: [PATCH 067/167] Fix for-await-of emit in async function --- src/compiler/transformers/esnext.ts | 22 ++++++++++++------- ...ter.asyncGenerators.classMethods.es2015.js | 9 ++++++++ ...mitter.asyncGenerators.classMethods.es5.js | 9 ++++++++ ...cGenerators.functionDeclarations.es2015.js | 7 ++++++ ...syncGenerators.functionDeclarations.es5.js | 7 ++++++ ...ncGenerators.functionExpressions.es2015.js | 7 ++++++ ...asyncGenerators.functionExpressions.es5.js | 7 ++++++ ...cGenerators.objectLiteralMethods.es2015.js | 7 ++++++ ...syncGenerators.objectLiteralMethods.es5.js | 7 ++++++ .../reference/emitter.forAwait.es2015.js | 14 ++++++++---- .../reference/emitter.forAwait.es5.js | 18 ++++++++++----- 11 files changed, 96 insertions(+), 18 deletions(-) diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 482f37d45f9..971dddd20ea 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -357,10 +357,12 @@ namespace ts { const values = createAsyncValuesHelper(context, expression, /*location*/ node.expression); const next = createYield( /*asteriskToken*/ undefined, - createArrayLiteral([ - createLiteral("await"), - createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []) - ]) + enclosingFunctionFlags & FunctionFlags.Generator + ? createArrayLiteral([ + createLiteral("await"), + createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []) + ]) + : createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []) ); hoistVariableDeclaration(errorRecord); @@ -431,10 +433,12 @@ namespace ts { createStatement( createYield( /*asteriskToken*/ undefined, - createArrayLiteral([ - createLiteral("await"), - createFunctionCall(returnMethod, iterator, []) - ]) + enclosingFunctionFlags & FunctionFlags.Generator + ? createArrayLiteral([ + createLiteral("await"), + createFunctionCall(returnMethod, iterator, []) + ]) + : createFunctionCall(returnMethod, iterator, []) ) ) ), @@ -872,6 +876,7 @@ namespace ts { scoped: false, text: ` var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -932,6 +937,7 @@ namespace ts { scoped: false, text: ` var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js index 2edcfd99e4b..ba4902102b1 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js @@ -62,6 +62,7 @@ class C9 extends B9 { //// [C1.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -81,6 +82,7 @@ class C1 { } //// [C2.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -101,6 +103,7 @@ class C2 { } //// [C3.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -126,6 +129,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -146,6 +150,7 @@ class C4 { } //// [C5.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -171,6 +176,7 @@ class C5 { } //// [C6.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -191,6 +197,7 @@ class C6 { } //// [C7.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -211,6 +218,7 @@ class C7 { } //// [C8.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -233,6 +241,7 @@ class C8 { } //// [C9.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js index 2b296936368..74a65673e5a 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js @@ -89,6 +89,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -141,6 +142,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -199,6 +201,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -262,6 +265,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -330,6 +334,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -410,6 +415,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -468,6 +474,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -520,6 +527,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -585,6 +593,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js index 97df064bbe8..2b0d6db5353 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js @@ -31,6 +31,7 @@ async function * f7() { //// [F1.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -48,6 +49,7 @@ function f1() { } //// [F2.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -66,6 +68,7 @@ function f2() { } //// [F3.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -89,6 +92,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -107,6 +111,7 @@ function f4() { } //// [F5.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -130,6 +135,7 @@ function f5() { } //// [F6.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -148,6 +154,7 @@ function f6() { } //// [F7.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js index 2a1b4393a9b..42098455ed1 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js @@ -58,6 +58,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -105,6 +106,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -158,6 +160,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -216,6 +219,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -279,6 +283,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -354,6 +359,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -407,6 +413,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js index bc64f029289..90f4b70e9bd 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js @@ -31,6 +31,7 @@ const f7 = async function * () { //// [F1.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -48,6 +49,7 @@ const f1 = function () { }; //// [F2.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -66,6 +68,7 @@ const f2 = function () { }; //// [F3.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -89,6 +92,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -107,6 +111,7 @@ const f4 = function () { }; //// [F5.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -130,6 +135,7 @@ const f5 = function () { }; //// [F6.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -148,6 +154,7 @@ const f6 = function () { }; //// [F7.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js index 9593562987b..a6265063fde 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js @@ -58,6 +58,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -105,6 +106,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -158,6 +160,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -216,6 +219,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -279,6 +283,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -354,6 +359,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -407,6 +413,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js index 3d3af24d030..817b3904f02 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js @@ -45,6 +45,7 @@ const o7 = { //// [O1.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -64,6 +65,7 @@ const o1 = { }; //// [O2.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -84,6 +86,7 @@ const o2 = { }; //// [O3.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -109,6 +112,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -129,6 +133,7 @@ const o4 = { }; //// [O5.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -154,6 +159,7 @@ const o5 = { }; //// [O6.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -174,6 +180,7 @@ const o6 = { }; //// [O7.js] var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js index f819945f288..a0839d8258d 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js @@ -72,6 +72,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -121,6 +122,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -176,6 +178,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -236,6 +239,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -301,6 +305,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -378,6 +383,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -433,6 +439,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } diff --git a/tests/baselines/reference/emitter.forAwait.es2015.js b/tests/baselines/reference/emitter.forAwait.es2015.js index bfd44581b82..a76c3e0b545 100644 --- a/tests/baselines/reference/emitter.forAwait.es2015.js +++ b/tests/baselines/reference/emitter.forAwait.es2015.js @@ -35,6 +35,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; @@ -42,14 +43,14 @@ function f1() { return __awaiter(this, void 0, void 0, function* () { let y; try { - for (var y_1 = __asyncValues(y), y_1_1 = yield ["await", y_1.next()]; !y_1_1.done; y_1_1 = yield ["await", y_1.next()]) { + for (var y_1 = __asyncValues(y), y_1_1 = yield y_1.next(); !y_1_1.done; y_1_1 = yield y_1.next()) { const x = y_1_1.value; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield ["await", _a.call(y_1)]; + if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield _a.call(y_1); } finally { if (e_1) throw e_1.error; } } @@ -66,6 +67,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; @@ -73,14 +75,14 @@ function f2() { return __awaiter(this, void 0, void 0, function* () { let x, y; try { - for (var y_1 = __asyncValues(y), y_1_1 = yield ["await", y_1.next()]; !y_1_1.done; y_1_1 = yield ["await", y_1.next()]) { + for (var y_1 = __asyncValues(y), y_1_1 = yield y_1.next(); !y_1_1.done; y_1_1 = yield y_1.next()) { x = y_1_1.value; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield ["await", _a.call(y_1)]; + if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield _a.call(y_1); } finally { if (e_1) throw e_1.error; } } @@ -89,10 +91,12 @@ function f2() { } //// [file3.js] var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -124,10 +128,12 @@ function f3() { } //// [file4.js] var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } diff --git a/tests/baselines/reference/emitter.forAwait.es5.js b/tests/baselines/reference/emitter.forAwait.es5.js index 5b904cf10a7..efbbe872b3f 100644 --- a/tests/baselines/reference/emitter.forAwait.es5.js +++ b/tests/baselines/reference/emitter.forAwait.es5.js @@ -62,6 +62,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; @@ -73,7 +74,7 @@ function f1() { case 0: _c.trys.push([0, 6, 7, 12]); y_1 = __asyncValues(y); - return [4 /*yield*/, ["await", y_1.next()]]; + return [4 /*yield*/, y_1.next()]; case 1: y_1_1 = _c.sent(); _c.label = 2; @@ -81,7 +82,7 @@ function f1() { if (!!y_1_1.done) return [3 /*break*/, 5]; x = y_1_1.value; _c.label = 3; - case 3: return [4 /*yield*/, ["await", y_1.next()]]; + case 3: return [4 /*yield*/, y_1.next()]; case 4: y_1_1 = _c.sent(); return [3 /*break*/, 2]; @@ -93,7 +94,7 @@ function f1() { case 7: _c.trys.push([7, , 10, 11]); if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; - return [4 /*yield*/, ["await", _b.call(y_1)]]; + return [4 /*yield*/, _b.call(y_1)]; case 8: _c.sent(); _c.label = 9; @@ -144,6 +145,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; @@ -155,7 +157,7 @@ function f2() { case 0: _c.trys.push([0, 6, 7, 12]); y_1 = __asyncValues(y); - return [4 /*yield*/, ["await", y_1.next()]]; + return [4 /*yield*/, y_1.next()]; case 1: y_1_1 = _c.sent(); _c.label = 2; @@ -163,7 +165,7 @@ function f2() { if (!!y_1_1.done) return [3 /*break*/, 5]; x = y_1_1.value; _c.label = 3; - case 3: return [4 /*yield*/, ["await", y_1.next()]]; + case 3: return [4 /*yield*/, y_1.next()]; case 4: y_1_1 = _c.sent(); return [3 /*break*/, 2]; @@ -175,7 +177,7 @@ function f2() { case 7: _c.trys.push([7, , 10, 11]); if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; - return [4 /*yield*/, ["await", _b.call(y_1)]]; + return [4 /*yield*/, _b.call(y_1)]; case 8: _c.sent(); _c.label = 9; @@ -218,10 +220,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } @@ -304,10 +308,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator]; return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), q = [], c, i; return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } From bb86e9e291a9a592af2f2ce43ebbe0eb946b4a18 Mon Sep 17 00:00:00 2001 From: Jason Jarrett Date: Sun, 19 Feb 2017 22:14:39 -0800 Subject: [PATCH 068/167] Update protocol.ts --- src/server/protocol.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index d8faad28b10..c7d27d80d25 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -820,7 +820,7 @@ namespace ts.server.protocol { * Represents a file in external project. * External project is project whose set of files, compilation options and open\close state * is maintained by the client (i.e. if all this data come from .csproj file in Visual Studio). - * External project will exist even if all files in it are closed and should be closed explicity. + * External project will exist even if all files in it are closed and should be closed explicitly. * If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will * create configured project for every config file but will maintain a link that these projects were created * as a result of opening external project so they should be removed once external project is closed. From a2f61a8041f0e539f656435aaaf956500236fb60 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 21 Feb 2017 10:27:50 -0800 Subject: [PATCH 069/167] handle the case when conversion of tsconfig.json failed (#14160) --- .../unittests/tsserverProjectSystem.ts | 27 +++++++++++++++++++ src/server/editorServices.ts | 4 +-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 92ec0b4ee0e..7446cc84deb 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3035,6 +3035,33 @@ namespace ts.projectSystem { const inferredProject = projectService.inferredProjects[0]; assert.isTrue(inferredProject.containsFile(file1.path)); }); + + it("should be able to handle @types if input file list is empty", () => { + const f = { + path: "/a/app.ts", + content: "let x = 1" + }; + const config = { + path: "/a/tsconfig.json", + content: JSON.stringify({ + compiler: {}, + files: [] + }) + }; + const t1 = { + path: "/a/node_modules/@types/typings/index.d.ts", + content: `export * from "./lib"` + }; + const t2 = { + path: "/a/node_modules/@types/typings/lib.d.ts", + content: `export const x: number` + }; + const host = createServerHost([f, config, t1, t2], { currentDirectory: getDirectoryPath(f.path) }); + const projectService = createProjectService(host); + + projectService.openClientFile(f.path); + projectService.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 }); + }); }); describe("reload", () => { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 36aa3939c83..d0535e2f528 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -948,9 +948,9 @@ namespace ts.server { private openConfigFile(configFileName: NormalizedPath, clientFileName?: string): OpenConfigFileResult { const conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); - const projectOptions = conversionResult.success + const projectOptions: ProjectOptions = conversionResult.success ? conversionResult.projectOptions - : { files: [], compilerOptions: {} }; + : { files: [], compilerOptions: {}, typeAcquisition: { enable: false } }; const project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); return { success: conversionResult.success, From c77ea9e9ea85373c324d67d42e0dae2276a28159 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 21 Feb 2017 13:59:33 -0800 Subject: [PATCH 070/167] ignore request for codefixes with no error codes (#14215) --- src/server/session.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server/session.ts b/src/server/session.ts index 262ba8da1da..f1b373c4a90 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1412,6 +1412,9 @@ namespace ts.server { } private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): protocol.CodeAction[] | CodeAction[] { + if (args.errorCodes.length === 0) { + return undefined; + } const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); const scriptInfo = project.getScriptInfoForNormalizedPath(file); From 5bcbd7aabc8f25a8fbcb68aa8c9b44eaa88561fc Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 22 Feb 2017 16:15:16 -0800 Subject: [PATCH 071/167] instantiate generic this param correctly --- src/compiler/checker.ts | 15 +++++++++++++-- src/compiler/utilities.ts | 8 ++++++++ ...ClassDoesntImplementInheritedAbstractMember.ts | 4 ++-- .../fixClassIncorrectlyImplementsInterface.ts | 4 ++-- src/services/codefixes/helpers.ts | 14 +++----------- .../fourslash/codeFixClassExtendAbstractMethod.ts | 2 ++ .../codeFixClassExtendAbstractMethodThis.ts | 13 +++++++++++++ .../codeFixClassExtendAbstractPropertyThis.ts | 11 +++++++++++ ...plementInterfaceMethodThisAndSelfReference.ts} | 4 ++-- 9 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts create mode 100644 tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts rename tests/cases/fourslash/{codeFixClassImplementInterfaceMethodWithParams.ts => codeFixClassImplementInterfaceMethodThisAndSelfReference.ts} (71%) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 12b55aa818b..9698f0cf4f0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21106,7 +21106,15 @@ namespace ts { } if (isPartOfTypeNode(node)) { - return getTypeFromTypeNode(node); + let typeFromTypeNode = getTypeFromTypeNode(node); + + if (typeFromTypeNode && isExpressionWithTypeArgumentsInClassImplementsClause(node)) { + const containingClass = getContainingClass(node); + const classType = getTypeOfNode(containingClass) as InterfaceType; + typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); + } + + return typeFromTypeNode; } if (isPartOfExpression(node)) { @@ -21116,7 +21124,10 @@ namespace ts { if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) { // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the // extends clause of a class. We handle that case here. - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + const classNode = getContainingClass(node); + const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)) as InterfaceType; classType; + const baseType = getBaseTypes(classType)[0]; baseType; + return baseType && getTypeWithThisArgument(baseType, classType.thisType); } if (isTypeDeclaration(node)) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 66bf693d831..9eb76405031 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3126,6 +3126,14 @@ namespace ts { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } + export function isExpressionWithTypeArgumentsInClassImplementsClause(node: Node): boolean { + return node.kind === SyntaxKind.ExpressionWithTypeArguments + && node.parent + && (node.parent).token === SyntaxKind.ImplementsKeyword + && node.parent.parent + && isClassLike(node.parent.parent); + } + export function isEntityNameExpression(node: Expression): node is EntityNameExpression { return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression && isEntityNameExpression((node).expression); diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index 22546e55ecc..16edce0a516 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -22,8 +22,8 @@ namespace ts.codefix { const classDecl = token.parent as ClassLikeDeclaration; const startPos = classDecl.members.pos; - const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; - const instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + const extendsNode = getClassExtendsHeritageClauseElement(classDecl); + const instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 42488dc2aed..856a57c46b7 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -17,7 +17,7 @@ namespace ts.codefix { } const startPos: number = classDecl.members.pos; - const classType = checker.getTypeAtLocation(classDecl); + const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDecl); const hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, IndexKind.Number); @@ -25,7 +25,7 @@ namespace ts.codefix { const result: CodeAction[] = []; for (const implementedTypeNode of implementedTypeNodes) { - const implementedType = checker.getTypeFromTypeNode(implementedTypeNode) as InterfaceType; + const implementedType = checker.getTypeAtLocation(implementedTypeNode) as InterfaceType; // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. const implementedTypeSymbols = checker.getPropertiesOfType(implementedType); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 45479e49474..d20fc0129cd 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -32,22 +32,14 @@ namespace ts.codefix { const name = declaration.name ? declaration.name.getText() : undefined; const visibility = getVisibilityPrefixWithSpace(getModifierFlags(declaration)); - const typeAtNewDeclaration = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); switch (declaration.kind) { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: - let typeString: string | undefined = undefined; - const typeAtOldDeclaration = checker.getTypeAtLocation(declaration); - if ((typeAtOldDeclaration as TypeParameter).isThisType) { - typeString = "this"; - } - else { - typeString = checker.typeToString(typeAtNewDeclaration, enclosingDeclaration, TypeFormatFlags.None); - } - + const typeString = checker.typeToString(type, enclosingDeclaration, TypeFormatFlags.None); return `${visibility}${name}: ${typeString};${newlineChar}`; case SyntaxKind.MethodSignature: @@ -59,7 +51,7 @@ namespace ts.codefix { // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - const signatures = checker.getSignaturesOfType(typeAtNewDeclaration, SignatureKind.Call); + const signatures = checker.getSignaturesOfType(type, SignatureKind.Call); if (!(signatures && signatures.length > 0)) { return ""; } diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts index a657dfeb718..344a7ee3f2b 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts @@ -2,6 +2,7 @@ //// abstract class A { //// abstract f(a: number, b: string): boolean; +//// abstract f(a: number, b: string): this; //// abstract f(a: string, b: number): Function; //// abstract f(a: string): Function; //// } @@ -10,6 +11,7 @@ verify.rangeAfterCodeFix(` f(a: number, b: string): boolean; + f(a: number, b: string): this; f(a: string, b: number): Function; f(a: string): Function; f(a: any, b?: any) { diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts new file mode 100644 index 00000000000..55b3ad4b77e --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts @@ -0,0 +1,13 @@ +/// + +//// abstract class A { +//// abstract f(): this; +//// } +//// +//// class C extends A {[| |]} + +verify.rangeAfterCodeFix(` + f(): this { + throw new Error('Method not implemented.'); + } +`); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts new file mode 100644 index 00000000000..de128ca1b79 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts @@ -0,0 +1,11 @@ +/// + +//// abstract class A { +//// abstract x: this; +//// } +//// +//// class C extends A {[| |]} + +verify.rangeAfterCodeFix(` + x: this; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts similarity index 71% rename from tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts rename to tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts index 0ee842975e0..95cc3476bf1 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts @@ -1,14 +1,14 @@ /// //// interface I { -//// f(x: number, y: string): I +//// f(x: number, y: this): I //// } //// //// class C implements I {[| //// |]} verify.rangeAfterCodeFix(` -f(x: number,y: string): I { +f(x: number,y: this): I { throw new Error('Method not implemented.'); } `); From 9d1b325e09f3f71071b213e819a8aa36b99b32e7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 1 Mar 2017 06:31:34 -0800 Subject: [PATCH 072/167] Update another test --- .../reference/thisInObjectLiterals.errors.txt | 29 +++++++++++++++++++ .../reference/thisInObjectLiterals.js | 1 + .../thisKeyword/thisInObjectLiterals.ts | 3 ++ 3 files changed, 33 insertions(+) create mode 100644 tests/baselines/reference/thisInObjectLiterals.errors.txt diff --git a/tests/baselines/reference/thisInObjectLiterals.errors.txt b/tests/baselines/reference/thisInObjectLiterals.errors.txt new file mode 100644 index 00000000000..52ff6789559 --- /dev/null +++ b/tests/baselines/reference/thisInObjectLiterals.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(15,5): error TS7023: 'f' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(16,21): error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'. + + +==== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts (2 errors) ==== + + class MyClass { + t: number; + + fn() { + type ContainingThis = this; + //type of 'this' in an object literal is the containing scope's this + var t = { x: this, y: this.t }; + var t: { x: ContainingThis; y: number }; + } + } + + //type of 'this' in an object literal method is the type of the object literal + var obj = { + f() { + ~ +!!! error TS7023: 'f' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + return this.spaaace; + ~~~~~~~ +!!! error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'. + } + }; + var obj: { f: () => any; }; + \ No newline at end of file diff --git a/tests/baselines/reference/thisInObjectLiterals.js b/tests/baselines/reference/thisInObjectLiterals.js index 6331f12105d..33a55cd5c71 100644 --- a/tests/baselines/reference/thisInObjectLiterals.js +++ b/tests/baselines/reference/thisInObjectLiterals.js @@ -1,4 +1,5 @@ //// [thisInObjectLiterals.ts] + class MyClass { t: number; diff --git a/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts b/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts index 6219586b6e5..7ba7d5b2e91 100644 --- a/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts +++ b/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts @@ -1,3 +1,6 @@ +// @noImplicitAny: true +// @noImplicitThis: true + class MyClass { t: number; From c8aa257a3009079c8d9b8147db1efbf3a49f8d6d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 1 Mar 2017 07:57:34 -0800 Subject: [PATCH 073/167] Fix gulp-typescript usage now that it is set to latest --- Gulpfile.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 633a1387ab6..3d4bae39a32 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -390,7 +390,7 @@ gulp.task(builtLocalCompiler, false, [servicesFile], () => { .pipe(localCompilerProject()) .pipe(prependCopyright()) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/compiler")); }); gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => { @@ -422,7 +422,7 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => { file.path = nodeStandaloneDefinitionsFile; return content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); })) - ]).pipe(gulp.dest(".")); + ]).pipe(gulp.dest("src/services")); }); // cancellationToken.js @@ -448,7 +448,7 @@ gulp.task(typingsInstallerJs, false, [servicesFile], () => { .pipe(cancellationTokenProject()) .pipe(prependCopyright()) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/server/typingsInstaller")); }); const serverFile = path.join(builtLocalDirectory, "tsserver.js"); @@ -461,7 +461,7 @@ gulp.task(serverFile, false, [servicesFile, typingsInstallerJs, cancellationToke .pipe(serverProject()) .pipe(prependCopyright()) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/server")); }); const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); @@ -556,7 +556,7 @@ gulp.task(run, false, [servicesFile], () => { .pipe(sourcemaps.init()) .pipe(testProject()) .pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" })) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/harness")); }); const internalTests = "internal/"; @@ -778,7 +778,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo }); })) .pipe(sourcemaps.write(".", { includeContent: false })) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/harness")); }); From 0f50a5ffa747d8459b8f2078284fec083071dbb0 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 1 Mar 2017 08:29:33 -0800 Subject: [PATCH 074/167] Move code from 'Completions' to 'PathCompletions' namespace --- src/services/completions.ts | 562 +------------------------------- src/services/pathCompletions.ts | 538 ++++++++++++++++++++++++++++++ src/services/tsconfig.json | 1 + 3 files changed, 552 insertions(+), 549 deletions(-) create mode 100644 src/services/pathCompletions.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 1bf57d33fdc..08e78227989 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1,10 +1,12 @@ +/// + /* @internal */ namespace ts.Completions { export type Log = (message: string) => void; export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: Log, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo | undefined { if (isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); + return PathCompletions.getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (isInString(sourceFile, position)) { @@ -171,7 +173,7 @@ namespace ts.Completions { // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + return PathCompletions.getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); } else if (isEqualityExpression(node.parent)) { // Get completions from the type of the other operand @@ -273,489 +275,6 @@ namespace ts.Completions { } } - function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): CompletionInfo { - const literalValue = normalizeSlashes(node.text); - - const scriptPath = node.getSourceFile().path; - const scriptDirectory = getDirectoryPath(scriptPath); - - const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); - let entries: CompletionEntry[]; - if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { - const extensions = getSupportedExtensions(compilerOptions); - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( - compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/false, span, compilerOptions, host, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment( - literalValue, scriptDirectory, extensions, /*includeExtensions*/false, span, host, scriptPath); - } - } - else { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries - }; - } - - /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option - */ - function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptPath: string, ignoreCase: boolean): string[] { - // Make all paths absolute/normalized if they are not already - rootDirs = map(rootDirs, rootDirectory => normalizePath(isRootedDiskPath(rootDirectory) ? rootDirectory : combinePaths(basePath, rootDirectory))); - - // Determine the path to the directory containing the script relative to the root directory it is contained within - let relativeDirectory: string; - for (const rootDirectory of rootDirs) { - if (containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - - // Now find a path for each potential directory that is to be merged with the one containing the script - return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); - } - - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, compilerOptions: CompilerOptions, host: LanguageServiceHost, exclude?: string): CompletionEntry[] { - const basePath = compilerOptions.project || host.getCurrentDirectory(); - const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - - const result: CompletionEntry[] = []; - - for (const baseDirectory of baseDirectories) { - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); - } - - return result; - } - - /** - * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. - */ - function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, host: LanguageServiceHost, exclude?: string, result: CompletionEntry[] = []): CompletionEntry[] { - if (fragment === undefined) { - fragment = ""; - } - - fragment = normalizeSlashes(fragment); - - /** - * Remove the basename from the path. Note that we don't use the basename to filter completions; - * the client is responsible for refining completions. - */ - fragment = getDirectoryPath(fragment); - - if (fragment === "") { - fragment = "." + directorySeparator; - } - - fragment = ensureTrailingDirectorySeparator(fragment); - - const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); - const baseDirectory = getDirectoryPath(absolutePath); - const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); - - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - const foundFiles = createMap(); - for (let filePath of files) { - filePath = normalizePath(filePath); - if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { - continue; - } - - const foundFileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); - - if (!foundFiles.get(foundFileName)) { - foundFiles.set(foundFileName, true); - } - } - - forEachKey(foundFiles, foundFile => { - result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); - }); - } - - // If possible, get folder completion as well - const directories = tryGetDirectories(host, baseDirectory); - - if (directories) { - for (const directory of directories) { - const directoryName = getBaseFileName(normalizePath(directory)); - - result.push(createCompletionEntryForModule(directoryName, ScriptElementKind.directory, span)); - } - } - } - - return result; - } - - /** - * Check all of the declared modules and those in node modules. Possible sources of modules: - * Modules that are found by the type checker - * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) - * Modules from node_modules (i.e. those listed in package.json) - * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions - */ - function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, span: TextSpan, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): CompletionEntry[] { - const { baseUrl, paths } = compilerOptions; - - let result: CompletionEntry[]; - - if (baseUrl) { - const fileExtensions = getSupportedExtensions(compilerOptions); - const projectDir = compilerOptions.project || host.getCurrentDirectory(); - const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span, host); - - if (paths) { - for (const path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (const pattern of paths[path]) { - for (const match of getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host)) { - result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (startsWith(path, fragment)) { - const entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - - for (const moduleName of enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host)) { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); - } - - return result; - } - - function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[], host: LanguageServiceHost): string[] { - if (host.readDirectory) { - const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - const normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); - const normalizedPrefixBase = getBaseFileName(normalizedPrefix); - - const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; - - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; - - const normalizedSuffix = normalizePath(parsed.suffix); - const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); - const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - const includeGlob = normalizedSuffix ? "**/*" : "./*"; - - const matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - const result: string[] = []; - - // Trim away prefix and suffix - for (const match of matches) { - const normalizedMatch = normalizePath(match); - if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { - continue; - } - - const start = completePrefix.length; - const length = normalizedMatch.length - start - normalizedSuffix.length; - - result.push(removeFileExtension(normalizedMatch.substr(start, length))); - } - return result; - } - } - } - - return undefined; - } - - function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions, typeChecker: TypeChecker, host: LanguageServiceHost): string[] { - // Check If this is a nested module - const isNestedModule = fragment.indexOf(directorySeparator) !== -1; - const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; - - // Get modules that the type checker picked up - const ambientModules = map(typeChecker.getAmbientModules(), sym => stripQuotes(sym.name)); - let nonRelativeModules = filter(ambientModules, moduleName => startsWith(moduleName, fragment)); - - // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because that's where the replacement span - // starts - if (isNestedModule) { - const moduleNameWithSeperator = ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = map(nonRelativeModules, moduleName => { - if (startsWith(fragment, moduleNameWithSeperator)) { - return moduleName.substr(moduleNameWithSeperator.length); - } - return moduleName; - }); - } - - - if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { - for (const visibleModule of enumerateNodeModulesVisibleToScript(host, scriptPath)) { - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (startsWith(visibleModule.moduleName, moduleNameFragment)) { - const nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); - if (nestedFiles) { - for (let f of nestedFiles) { - f = normalizePath(f); - const nestedModule = removeFileExtension(getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - - return deduplicate(nonRelativeModules); - } - - function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number, compilerOptions: CompilerOptions, host: LanguageServiceHost): CompletionInfo { - const token = getTokenAtPosition(sourceFile, position); - if (!token) { - return undefined; - } - const commentRanges: CommentRange[] = getLeadingCommentRanges(sourceFile.text, token.pos); - - if (!commentRanges || !commentRanges.length) { - return undefined; - } - - const range = forEach(commentRanges, commentRange => position >= commentRange.pos && position <= commentRange.end && commentRange); - - if (!range) { - return undefined; - } - - const completionInfo: CompletionInfo = { - /** - * We don't want the editor to offer any other completions, such as snippets, inside a comment. - */ - isGlobalCompletion: false, - isMemberCompletion: false, - /** - * The user may type in a path that doesn't yet exist, creating a "new identifier" - * with respect to the collection of identifiers the server is aware of. - */ - isNewIdentifierLocation: true, - - entries: [] - }; - - const text = sourceFile.text.substr(range.pos, position - range.pos); - - const match = tripleSlashDirectiveFragmentRegex.exec(text); - - if (match) { - const prefix = match[1]; - const kind = match[2]; - const toComplete = match[3]; - - const scriptPath = getDirectoryPath(sourceFile.path); - if (kind === "path") { - // Give completions for a relative path - const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, host, sourceFile.path); - } - else { - // Give completions based on the typings available - const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span); - } - } - - return completionInfo; - } - - function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: CompletionEntry[] = []): CompletionEntry[] { - // Check for typings specified in compiler options - if (options.types) { - for (const moduleName of options.types) { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - let typeRoots: string[]; - try { - // Wrap in try catch because getEffectiveTypeRoots touches the filesystem - typeRoots = getEffectiveTypeRoots(options, host); - } - catch (e) {} - - if (typeRoots) { - for (const root of typeRoots) { - getCompletionEntriesFromDirectories(host, root, span, result); - } - } - } - - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (const packageJson of findPackageJsons(scriptPath, host)) { - const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - - return result; - } - - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: Push) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - const directories = tryGetDirectories(host, directory); - if (directories) { - for (let typeDirectory of directories) { - typeDirectory = normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span)); - } - } - } - } - - function findPackageJsons(currentDir: string, host: LanguageServiceHost): string[] { - const paths: string[] = []; - let currentConfigPath: string; - while (true) { - currentConfigPath = findConfigFile(currentDir, (f) => tryFileExists(host, f), "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - - currentDir = getDirectoryPath(currentConfigPath); - const parent = getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } - - return paths; - } - - function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { - const result: VisibleModuleInfo[] = []; - - if (host.readFile && host.fileExists) { - for (const packageJson of findPackageJsons(scriptPath, host)) { - const contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - - const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); - const foundModuleNames: string[] = []; - - // Provide completions for all non @types dependencies - for (const key of nodeModulesDependencyKeys) { - addPotentialPackageNames(contents[key], foundModuleNames); - } - - for (const moduleName of foundModuleNames) { - const moduleDir = combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName, - moduleDir - }); - } - } - } - - return result; - - function tryReadingPackageJson(filePath: string) { - try { - const fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - - function addPotentialPackageNames(dependencies: any, result: string[]) { - if (dependencies) { - for (const dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - - function createCompletionEntryForModule(name: string, kind: string, replacementSpan: TextSpan): CompletionEntry { - return { name, kind, kindModifiers: ScriptElementKindModifier.none, sortText: name, replacementSpan }; - } - - // Replace everything after the last directory seperator that appears - function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan { - const index = text.lastIndexOf(directorySeparator); - const offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - - // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) - function isPathRelativeToScript(path: string) { - if (path && path.length >= 2 && path.charCodeAt(0) === CharacterCodes.dot) { - const slashIndex = path.length >= 3 && path.charCodeAt(1) === CharacterCodes.dot ? 2 : 1; - const slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === CharacterCodes.slash || slashCharCode === CharacterCodes.backslash; - } - return false; - } - - function normalizeAndPreserveTrailingSlash(path: string) { - return hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalizePath(path)) : normalizePath(path); - } - export function getCompletionEntryDetails(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): CompletionEntryDetails { // Compute all the completion symbols again. const completionData = getCompletionData(typeChecker, log, sourceFile, position); @@ -1457,20 +976,18 @@ namespace ts.Completions { } function isFunction(kind: SyntaxKind): boolean { + if (!isFunctionLikeKind(kind)) { + return false; + } + switch (kind) { - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: + case SyntaxKind.Constructor: + case SyntaxKind.ConstructorType: + case SyntaxKind.FunctionType: + return false; + default: return true; } - return false; } /** @@ -1748,59 +1265,6 @@ namespace ts.Completions { }); } - /** - * Matches a triple slash reference directive with an incomplete string literal for its path. Used - * to determine if the caret is currently within the string literal and capture the literal fragment - * for completions. - * For example, this matches - * - * /// (host: LanguageServiceHost, toApply: (...a: any[]) => T, ...args: any[]) { - try { - return toApply && toApply.apply(host, args); - } - catch (e) {} - return undefined; - } - function isEqualityExpression(node: Node): node is BinaryExpression { return isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); } diff --git a/src/services/pathCompletions.ts b/src/services/pathCompletions.ts new file mode 100644 index 00000000000..96597da9d2d --- /dev/null +++ b/src/services/pathCompletions.ts @@ -0,0 +1,538 @@ +/* @internal */ +namespace ts.Completions.PathCompletions { + export function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): CompletionInfo { + const literalValue = normalizeSlashes(node.text); + + const scriptPath = node.getSourceFile().path; + const scriptDirectory = getDirectoryPath(scriptPath); + + const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); + let entries: CompletionEntry[]; + if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { + const extensions = getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( + compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment( + literalValue, scriptDirectory, extensions, /*includeExtensions*/false, span, host, scriptPath); + } + } + else { + // Check for node modules + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries + }; + } + + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptPath: string, ignoreCase: boolean): string[] { + // Make all paths absolute/normalized if they are not already + rootDirs = map(rootDirs, rootDirectory => normalizePath(isRootedDiskPath(rootDirectory) ? rootDirectory : combinePaths(basePath, rootDirectory))); + + // Determine the path to the directory containing the script relative to the root directory it is contained within + let relativeDirectory: string; + for (const rootDirectory of rootDirs) { + if (containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + + // Now find a path for each potential directory that is to be merged with the one containing the script + return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); + } + + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, compilerOptions: CompilerOptions, host: LanguageServiceHost, exclude?: string): CompletionEntry[] { + const basePath = compilerOptions.project || host.getCurrentDirectory(); + const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + + const result: CompletionEntry[] = []; + + for (const baseDirectory of baseDirectories) { + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + + return result; + } + + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ + function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, host: LanguageServiceHost, exclude?: string, result: CompletionEntry[] = []): CompletionEntry[] { + if (fragment === undefined) { + fragment = ""; + } + + fragment = normalizeSlashes(fragment); + + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ + fragment = getDirectoryPath(fragment); + + if (fragment === "") { + fragment = "." + directorySeparator; + } + + fragment = ensureTrailingDirectorySeparator(fragment); + + const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); + const baseDirectory = getDirectoryPath(absolutePath); + const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); + + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + const foundFiles = createMap(); + for (let filePath of files) { + filePath = normalizePath(filePath); + if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { + continue; + } + + const foundFileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); + + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + + forEachKey(foundFiles, foundFile => { + result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); + }); + } + + // If possible, get folder completion as well + const directories = tryGetDirectories(host, baseDirectory); + + if (directories) { + for (const directory of directories) { + const directoryName = getBaseFileName(normalizePath(directory)); + + result.push(createCompletionEntryForModule(directoryName, ScriptElementKind.directory, span)); + } + } + } + + return result; + } + + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, span: TextSpan, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): CompletionEntry[] { + const { baseUrl, paths } = compilerOptions; + + let result: CompletionEntry[]; + + if (baseUrl) { + const fileExtensions = getSupportedExtensions(compilerOptions); + const projectDir = compilerOptions.project || host.getCurrentDirectory(); + const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span, host); + + if (paths) { + for (const path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (const pattern of paths[path]) { + for (const match of getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host)) { + result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (startsWith(path, fragment)) { + const entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName, span)); + } + } + } + } + } + } + else { + result = []; + } + + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + + for (const moduleName of enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host)) { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + } + + return result; + } + + function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[], host: LanguageServiceHost): string[] { + if (host.readDirectory) { + const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + const normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); + const normalizedPrefixBase = getBaseFileName(normalizedPrefix); + + const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; + + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; + + const normalizedSuffix = normalizePath(parsed.suffix); + const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); + const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + const includeGlob = normalizedSuffix ? "**/*" : "./*"; + + const matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + const result: string[] = []; + + // Trim away prefix and suffix + for (const match of matches) { + const normalizedMatch = normalizePath(match); + if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { + continue; + } + + const start = completePrefix.length; + const length = normalizedMatch.length - start - normalizedSuffix.length; + + result.push(removeFileExtension(normalizedMatch.substr(start, length))); + } + return result; + } + } + } + + return undefined; + } + + function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions, typeChecker: TypeChecker, host: LanguageServiceHost): string[] { + // Check If this is a nested module + const isNestedModule = fragment.indexOf(directorySeparator) !== -1; + const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; + + // Get modules that the type checker picked up + const ambientModules = map(typeChecker.getAmbientModules(), sym => stripQuotes(sym.name)); + let nonRelativeModules = filter(ambientModules, moduleName => startsWith(moduleName, fragment)); + + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + const moduleNameWithSeperator = ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = map(nonRelativeModules, moduleName => { + if (startsWith(fragment, moduleNameWithSeperator)) { + return moduleName.substr(moduleNameWithSeperator.length); + } + return moduleName; + }); + } + + + if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { + for (const visibleModule of enumerateNodeModulesVisibleToScript(host, scriptPath)) { + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (startsWith(visibleModule.moduleName, moduleNameFragment)) { + const nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); + if (nestedFiles) { + for (let f of nestedFiles) { + f = normalizePath(f); + const nestedModule = removeFileExtension(getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } + } + } + + return deduplicate(nonRelativeModules); + } + + export function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number, compilerOptions: CompilerOptions, host: LanguageServiceHost): CompletionInfo { + const token = getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + const commentRanges: CommentRange[] = getLeadingCommentRanges(sourceFile.text, token.pos); + + if (!commentRanges || !commentRanges.length) { + return undefined; + } + + const range = forEach(commentRanges, commentRange => position >= commentRange.pos && position <= commentRange.end && commentRange); + + if (!range) { + return undefined; + } + + const completionInfo: CompletionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + + entries: [] + }; + + const text = sourceFile.text.substr(range.pos, position - range.pos); + + const match = tripleSlashDirectiveFragmentRegex.exec(text); + + if (match) { + const prefix = match[1]; + const kind = match[2]; + const toComplete = match[3]; + + const scriptPath = getDirectoryPath(sourceFile.path); + if (kind === "path") { + // Give completions for a relative path + const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, host, sourceFile.path); + } + else { + // Give completions based on the typings available + const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span); + } + } + + return completionInfo; + } + + function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: CompletionEntry[] = []): CompletionEntry[] { + // Check for typings specified in compiler options + if (options.types) { + for (const moduleName of options.types) { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + let typeRoots: string[]; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = getEffectiveTypeRoots(options, host); + } + catch (e) {} + + if (typeRoots) { + for (const root of typeRoots) { + getCompletionEntriesFromDirectories(host, root, span, result); + } + } + } + + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + for (const packageJson of findPackageJsons(scriptPath, host)) { + const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + + return result; + } + + function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: Push) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + const directories = tryGetDirectories(host, directory); + if (directories) { + for (let typeDirectory of directories) { + typeDirectory = normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span)); + } + } + } + } + + function findPackageJsons(currentDir: string, host: LanguageServiceHost): string[] { + const paths: string[] = []; + let currentConfigPath: string; + while (true) { + currentConfigPath = findConfigFile(currentDir, (f) => tryFileExists(host, f), "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + + currentDir = getDirectoryPath(currentConfigPath); + const parent = getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { + break; + } + } + + return paths; + } + + function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { + const result: VisibleModuleInfo[] = []; + + if (host.readFile && host.fileExists) { + for (const packageJson of findPackageJsons(scriptPath, host)) { + const contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + + const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); + const foundModuleNames: string[] = []; + + // Provide completions for all non @types dependencies + for (const key of nodeModulesDependencyKeys) { + addPotentialPackageNames(contents[key], foundModuleNames); + } + + for (const moduleName of foundModuleNames) { + const moduleDir = combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName, + moduleDir + }); + } + } + } + + return result; + + function tryReadingPackageJson(filePath: string) { + try { + const fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; + } + catch (e) { + return undefined; + } + } + + function addPotentialPackageNames(dependencies: any, result: string[]) { + if (dependencies) { + for (const dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types/")) { + result.push(dep); + } + } + } + } + } + + function createCompletionEntryForModule(name: string, kind: string, replacementSpan: TextSpan): CompletionEntry { + return { name, kind, kindModifiers: ScriptElementKindModifier.none, sortText: name, replacementSpan }; + } + + // Replace everything after the last directory seperator that appears + function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan { + const index = text.lastIndexOf(directorySeparator); + const offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path: string) { + if (path && path.length >= 2 && path.charCodeAt(0) === CharacterCodes.dot) { + const slashIndex = path.length >= 3 && path.charCodeAt(1) === CharacterCodes.dot ? 2 : 1; + const slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === CharacterCodes.slash || slashCharCode === CharacterCodes.backslash; + } + return false; + } + + function normalizeAndPreserveTrailingSlash(path: string) { + return hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalizePath(path)) : normalizePath(path); + } + + /** + * Matches a triple slash reference directive with an incomplete string literal for its path. Used + * to determine if the caret is currently within the string literal and capture the literal fragment + * for completions. + * For example, this matches + * + * /// (host: LanguageServiceHost, toApply: (...a: any[]) => T, ...args: any[]) { + try { + return toApply && toApply.apply(host, args); + } + catch (e) {} + return undefined; + } +} diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index ae2150d981d..93f861e80aa 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -53,6 +53,7 @@ "navigateTo.ts", "navigationBar.ts", "outliningElementsCollector.ts", + "pathCompletions.ts", "patternMatcher.ts", "preProcess.ts", "rename.ts", From 9ac2ea722db7db8d17bd200e1563ca20b5d88960 Mon Sep 17 00:00:00 2001 From: Magnus Hiie Date: Wed, 1 Mar 2017 18:48:08 +0200 Subject: [PATCH 075/167] Add insert...Braces Option to Server Protocol Closes #13275 --- lib/protocol.d.ts | 1 + src/server/protocol.ts | 1 + tests/cases/fourslash/fourslash.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index 2fc15c3a256..e675ba87417 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -1742,6 +1742,7 @@ declare namespace ts.server.protocol { insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceBeforeFunctionParenthesis?: boolean; diff --git a/src/server/protocol.ts b/src/server/protocol.ts index c7d27d80d25..d054867cd1c 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2218,6 +2218,7 @@ namespace ts.server.protocol { insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceBeforeFunctionParenthesis?: boolean; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 34afb71ec85..ab83752d93b 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -92,6 +92,7 @@ declare namespace FourSlashInterface { InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterTypeAssertion: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; From 6ad9fe146a9f80028ecc7b8abc9df7faf7d56824 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Wed, 1 Mar 2017 18:08:53 +0100 Subject: [PATCH 076/167] Add parent type to ExpressionWithTypeArguments --- src/compiler/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3d93907ae98..bce435a7e6f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1446,6 +1446,7 @@ export interface ExpressionWithTypeArguments extends TypeNode { kind: SyntaxKind.ExpressionWithTypeArguments; + parent?: HeritageClause; expression: LeftHandSideExpression; typeArguments?: NodeArray; } From 9bef19c54c629e8b4a109706ef8bfa118afd66f9 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 1 Mar 2017 09:19:47 -0800 Subject: [PATCH 077/167] Fix JsDoc tagname in tests --- tests/cases/fourslash/completionInJsDoc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts index 5eca52743a4..cf8a448bf19 100644 --- a/tests/cases/fourslash/completionInJsDoc.ts +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -71,7 +71,7 @@ verify.completionListContains("@argument"); goTo.marker('10'); verify.completionListCount(40); -verify.completionListContains("@return"); +verify.completionListContains("@returns"); goTo.marker('11'); verify.completionListCount(40); From 8371eb6401b9452d1ed7787001a876eb96b9b009 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 1 Mar 2017 09:28:51 -0800 Subject: [PATCH 078/167] Update tslint to `latest` (`next` is still on 4.3) and lint for BOM --- Jakefile.js | 3 +- package.json | 2 +- scripts/tslint/booleanTriviaRule.ts | 78 +++++++++++-------- scripts/tslint/nextLineRule.ts | 76 +++++++++--------- scripts/tslint/noBomRule.ts | 16 ++++ scripts/tslint/noInOperatorRule.ts | 13 ++-- scripts/tslint/noIncrementDecrementRule.ts | 59 ++++++++------ .../tslint/noTypeAssertionWhitespaceRule.ts | 12 +-- .../objectLiteralSurroundingSpaceRule.ts | 52 +++++++------ scripts/tslint/tsconfig.json | 5 ++ scripts/tslint/typeOperatorSpacingRule.ts | 38 ++++----- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 2 +- src/compiler/commandLineParser.ts | 2 +- src/compiler/core.ts | 2 +- src/compiler/emitter.ts | 2 +- src/compiler/factory.ts | 2 +- src/compiler/sys.ts | 2 +- src/compiler/transformer.ts | 2 +- src/compiler/transformers/generators.ts | 2 +- src/compiler/transformers/module/module.ts | 2 +- src/compiler/transformers/module/system.ts | 2 +- src/compiler/transformers/ts.ts | 2 +- src/compiler/tsc.ts | 2 +- src/compiler/types.ts | 2 +- src/compiler/utilities.ts | 2 +- src/compiler/visitor.ts | 2 +- src/harness/fourslash.ts | 2 +- .../unittests/cachingInServerLSHost.ts | 2 +- src/harness/unittests/initializeTSConfig.ts | 2 +- .../unittests/reuseProgramStructure.ts | 2 +- .../unittests/services/colorization.ts | 2 +- .../unittests/services/preProcessFile.ts | 2 +- src/harness/unittests/session.ts | 2 +- .../unittests/tsserverProjectSystem.ts | 2 +- src/harness/unittests/typingsInstaller.ts | 2 +- .../cancellationToken/cancellationToken.ts | 2 +- src/server/editorServices.ts | 2 +- src/server/project.ts | 2 +- src/server/session.ts | 2 +- .../typingsInstaller/nodeTypingsInstaller.ts | 2 +- .../typingsInstaller/typingsInstaller.ts | 2 +- src/services/codeFixProvider.ts | 2 +- src/services/codefixes/importFixes.ts | 2 +- .../codefixes/unusedIdentifierFixes.ts | 2 +- src/services/documentRegistry.ts | 2 +- src/services/findAllReferences.ts | 2 +- src/services/goToDefinition.ts | 2 +- src/services/jsDoc.ts | 2 +- src/services/jsTyping.ts | 2 +- src/services/navigateTo.ts | 2 +- src/services/services.ts | 2 +- src/services/transpile.ts | 2 +- src/services/utilities.ts | 2 +- tslint.json | 1 + 55 files changed, 247 insertions(+), 194 deletions(-) create mode 100644 scripts/tslint/noBomRule.ts diff --git a/Jakefile.js b/Jakefile.js index f8be7c2b671..17152285f2a 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1098,7 +1098,8 @@ var tslintRules = [ "noInOperatorRule", "noIncrementDecrementRule", "objectLiteralSurroundingSpaceRule", - "noTypeAssertionWhitespaceRule" + "noTypeAssertionWhitespaceRule", + "noBomRule" ]; var tslintRulesFiles = tslintRules.map(function (p) { return path.join(tslintRuleDir, p + ".ts"); diff --git a/package.json b/package.json index 3ffab4bfb13..8b52eb6675e 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "through2": "latest", "travis-fold": "latest", "ts-node": "latest", - "tslint": "next", + "tslint": "latest", "typescript": "next" }, "scripts": { diff --git a/scripts/tslint/booleanTriviaRule.ts b/scripts/tslint/booleanTriviaRule.ts index db6abcbf17b..e79275c6392 100644 --- a/scripts/tslint/booleanTriviaRule.ts +++ b/scripts/tslint/booleanTriviaRule.ts @@ -2,52 +2,62 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; export class Rule extends Lint.Rules.AbstractRule { - public static FAILURE_STRING_FACTORY = (name: string, currently: string) => `Tag boolean argument as '${name}' (currently '${currently}')`; + public static FAILURE_STRING_FACTORY(name: string, currently?: string): string { + const current = currently ? ` (currently '${currently}')` : ""; + return `Tag boolean argument as '${name}'${current}`; + } public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + // Cheat to get type checker const program = ts.createProgram([sourceFile.fileName], Lint.createCompilerOptions()); const checker = program.getTypeChecker(); - return this.applyWithWalker(new BooleanTriviaWalker(checker, program.getSourceFile(sourceFile.fileName), this.getOptions())); + return this.applyWithFunction(program.getSourceFile(sourceFile.fileName), ctx => walk(ctx, checker)); } } -class BooleanTriviaWalker extends Lint.RuleWalker { - constructor(private checker: ts.TypeChecker, file: ts.SourceFile, opts: Lint.IOptions) { - super(file, opts); +function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker): void { + ts.forEachChild(ctx.sourceFile, recur); + function recur(node: ts.Node): void { + if (node.kind === ts.SyntaxKind.CallExpression) { + checkCall(node as ts.CallExpression); + } + ts.forEachChild(node, recur); } - visitCallExpression(node: ts.CallExpression) { - super.visitCallExpression(node); - if (node.arguments && node.arguments.some(arg => arg.kind === ts.SyntaxKind.TrueKeyword || arg.kind === ts.SyntaxKind.FalseKeyword)) { - const targetCallSignature = this.checker.getResolvedSignature(node); - if (!!targetCallSignature) { - const targetParameters = targetCallSignature.getParameters(); - const source = this.getSourceFile(); - for (let index = 0; index < targetParameters.length; index++) { - const param = targetParameters[index]; - const arg = node.arguments[index]; - if (!(arg && param)) { - continue; - } + function checkCall(node: ts.CallExpression): void { + if (!node.arguments || !node.arguments.some(arg => arg.kind === ts.SyntaxKind.TrueKeyword || arg.kind === ts.SyntaxKind.FalseKeyword)) { + return; + } - const argType = this.checker.getContextualType(arg); - if (argType && (argType.getFlags() & ts.TypeFlags.Boolean)) { - if (arg.kind !== ts.SyntaxKind.TrueKeyword && arg.kind !== ts.SyntaxKind.FalseKeyword) { - continue; - } - let triviaContent: string; - const ranges = ts.getLeadingCommentRanges(arg.getFullText(), 0); - if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) { - triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); // +/-2 to remove /**/ - } + const targetCallSignature = checker.getResolvedSignature(node); + if (!targetCallSignature) { + return; + } - const paramName = param.getName(); - if (triviaContent !== paramName && triviaContent !== paramName + ":") { - this.addFailure(this.createFailure(arg.getStart(source), arg.getWidth(source), Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent))); - } - } + const targetParameters = targetCallSignature.getParameters(); + for (let index = 0; index < targetParameters.length; index++) { + const param = targetParameters[index]; + const arg = node.arguments[index]; + if (!(arg && param)) { + continue; + } + + const argType = checker.getContextualType(arg); + if (argType && (argType.getFlags() & ts.TypeFlags.Boolean)) { + if (arg.kind !== ts.SyntaxKind.TrueKeyword && arg.kind !== ts.SyntaxKind.FalseKeyword) { + continue; + } + let triviaContent: string | undefined; + const ranges = ts.getLeadingCommentRanges(arg.getFullText(), 0); + if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) { + triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); // +/-2 to remove /**/ + } + + const paramName = param.getName(); + if (triviaContent !== paramName && triviaContent !== paramName + ":") { + ctx.addFailureAtNode(arg, Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent)); } } } } -} +} \ No newline at end of file diff --git a/scripts/tslint/nextLineRule.ts b/scripts/tslint/nextLineRule.ts index 2dee393bd84..b149d09eb38 100644 --- a/scripts/tslint/nextLineRule.ts +++ b/scripts/tslint/nextLineRule.ts @@ -9,50 +9,56 @@ export class Rule extends Lint.Rules.AbstractRule { public static ELSE_FAILURE_STRING = "'else' should not be on the same line as the preceeding block's curly brace"; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new NextLineWalker(sourceFile, this.getOptions())); + const options = this.getOptions().ruleArguments; + const checkCatch = options.indexOf(OPTION_CATCH) !== -1; + const checkElse = options.indexOf(OPTION_ELSE) !== -1; + return this.applyWithFunction(sourceFile, ctx => walk(ctx, checkCatch, checkElse)); } } -class NextLineWalker extends Lint.RuleWalker { - public visitIfStatement(node: ts.IfStatement) { - const sourceFile = node.getSourceFile(); - const thenStatement = node.thenStatement; - - const elseStatement = node.elseStatement; - if (!!elseStatement) { - // find the else keyword - const elseKeyword = getFirstChildOfKind(node, ts.SyntaxKind.ElseKeyword); - if (this.hasOption(OPTION_ELSE) && !!elseKeyword) { - const thenStatementEndLoc = sourceFile.getLineAndCharacterOfPosition(thenStatement.getEnd()); - const elseKeywordLoc = sourceFile.getLineAndCharacterOfPosition(elseKeyword.getStart(sourceFile)); - if (thenStatementEndLoc.line === elseKeywordLoc.line) { - const failure = this.createFailure(elseKeyword.getStart(sourceFile), elseKeyword.getWidth(sourceFile), Rule.ELSE_FAILURE_STRING); - this.addFailure(failure); - } - } +function walk(ctx: Lint.WalkContext, checkCatch: boolean, checkElse: boolean): void { + const { sourceFile } = ctx; + function recur(node: ts.Node): void { + switch (node.kind) { + case ts.SyntaxKind.IfStatement: + checkIf(node as ts.IfStatement); + break; + case ts.SyntaxKind.TryStatement: + checkTry(node as ts.TryStatement); + break; } - - super.visitIfStatement(node); + ts.forEachChild(node, recur); } - public visitTryStatement(node: ts.TryStatement) { - const sourceFile = node.getSourceFile(); - const catchClause = node.catchClause; + function checkIf(node: ts.IfStatement): void { + const { thenStatement, elseStatement } = node; + if (!elseStatement) { + return; + } - // "visit" try block - const tryBlock = node.tryBlock; - - if (this.hasOption(OPTION_CATCH) && !!catchClause) { - const tryClosingBrace = tryBlock.getLastToken(sourceFile); - const catchKeyword = catchClause.getFirstToken(sourceFile); - const tryClosingBraceLoc = sourceFile.getLineAndCharacterOfPosition(tryClosingBrace.getEnd()); - const catchKeywordLoc = sourceFile.getLineAndCharacterOfPosition(catchKeyword.getStart(sourceFile)); - if (tryClosingBraceLoc.line === catchKeywordLoc.line) { - const failure = this.createFailure(catchKeyword.getStart(sourceFile), catchKeyword.getWidth(sourceFile), Rule.CATCH_FAILURE_STRING); - this.addFailure(failure); + // find the else keyword + const elseKeyword = getFirstChildOfKind(node, ts.SyntaxKind.ElseKeyword); + if (checkElse && !!elseKeyword) { + const thenStatementEndLoc = sourceFile.getLineAndCharacterOfPosition(thenStatement.getEnd()); + const elseKeywordLoc = sourceFile.getLineAndCharacterOfPosition(elseKeyword.getStart(sourceFile)); + if (thenStatementEndLoc.line === elseKeywordLoc.line) { + ctx.addFailureAtNode(elseKeyword, Rule.ELSE_FAILURE_STRING); } } - super.visitTryStatement(node); + } + + function checkTry({ tryBlock, catchClause }: ts.TryStatement): void { + if (!checkCatch || !catchClause) { + return; + } + + const tryClosingBrace = tryBlock.getLastToken(sourceFile); + const catchKeyword = catchClause.getFirstToken(sourceFile); + const tryClosingBraceLoc = sourceFile.getLineAndCharacterOfPosition(tryClosingBrace.getEnd()); + const catchKeywordLoc = sourceFile.getLineAndCharacterOfPosition(catchKeyword.getStart(sourceFile)); + if (tryClosingBraceLoc.line === catchKeywordLoc.line) { + ctx.addFailureAtNode(catchKeyword, Rule.CATCH_FAILURE_STRING); + } } } diff --git a/scripts/tslint/noBomRule.ts b/scripts/tslint/noBomRule.ts new file mode 100644 index 00000000000..105e2d2d68c --- /dev/null +++ b/scripts/tslint/noBomRule.ts @@ -0,0 +1,16 @@ +import * as Lint from "tslint/lib"; +import * as ts from "typescript"; + +export class Rule extends Lint.Rules.AbstractRule { + public static FAILURE_STRING = "This file has a BOM."; + + public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + return this.applyWithFunction(sourceFile, walk); + } +} + +function walk(ctx: Lint.WalkContext): void { + if (ctx.sourceFile.text[0] === "\ufeff") { + ctx.addFailure(0, 1, Rule.FAILURE_STRING); + } +} diff --git a/scripts/tslint/noInOperatorRule.ts b/scripts/tslint/noInOperatorRule.ts index 307f0dffd6a..95f052ccaa6 100644 --- a/scripts/tslint/noInOperatorRule.ts +++ b/scripts/tslint/noInOperatorRule.ts @@ -1,20 +1,19 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static FAILURE_STRING = "Don't use the 'in' keyword - use 'hasProperty' to check for key presence instead"; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new InWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class InWalker extends Lint.RuleWalker { - visitNode(node: ts.Node) { - super.visitNode(node); - if (node.kind === ts.SyntaxKind.InKeyword && node.parent && node.parent.kind === ts.SyntaxKind.BinaryExpression) { - this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING)); +function walk(ctx: Lint.WalkContext): void { + ts.forEachChild(ctx.sourceFile, recur); + function recur(node: ts.Node): void { + if (node.kind === ts.SyntaxKind.InKeyword && node.parent.kind === ts.SyntaxKind.BinaryExpression) { + ctx.addFailureAtNode(node, Rule.FAILURE_STRING); } } } diff --git a/scripts/tslint/noIncrementDecrementRule.ts b/scripts/tslint/noIncrementDecrementRule.ts index 2a957b36af5..ff2d81b1962 100644 --- a/scripts/tslint/noIncrementDecrementRule.ts +++ b/scripts/tslint/noIncrementDecrementRule.ts @@ -1,44 +1,55 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static POSTFIX_FAILURE_STRING = "Don't use '++' or '--' postfix operators outside statements or for loops."; public static PREFIX_FAILURE_STRING = "Don't use '++' or '--' prefix operators."; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new IncrementDecrementWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class IncrementDecrementWalker extends Lint.RuleWalker { +function walk(ctx: Lint.WalkContext): void { + ts.forEachChild(ctx.sourceFile, recur); + function recur(node: ts.Node): void { + switch (node.kind) { + case ts.SyntaxKind.PrefixUnaryExpression: + const { operator } = node as ts.PrefixUnaryExpression; + if (operator === ts.SyntaxKind.PlusPlusToken || operator === ts.SyntaxKind.MinusMinusToken) { + check(node as ts.PrefixUnaryExpression); + } + break; - visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression) { - super.visitPostfixUnaryExpression(node); - if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator == ts.SyntaxKind.MinusMinusToken) { - this.visitIncrementDecrement(node); + case ts.SyntaxKind.PostfixUnaryExpression: + check(node as ts.PostfixUnaryExpression); + break; } } - visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression) { - super.visitPrefixUnaryExpression(node); - if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator == ts.SyntaxKind.MinusMinusToken) { - this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.PREFIX_FAILURE_STRING)); + function check(node: ts.UnaryExpression): void { + if (!isAllowedLocation(node.parent!)) { + ctx.addFailureAtNode(node, Rule.POSTFIX_FAILURE_STRING); } } +} - visitIncrementDecrement(node: ts.UnaryExpression) { - if (node.parent && ( - // Can be a statement - node.parent.kind === ts.SyntaxKind.ExpressionStatement || - // Can be directly in a for-statement - node.parent.kind === ts.SyntaxKind.ForStatement || - // Can be in a comma operator in a for statement (`for (let a = 0, b = 10; a < b; a++, b--)`) - node.parent.kind === ts.SyntaxKind.BinaryExpression && - (node.parent).operatorToken.kind === ts.SyntaxKind.CommaToken && - node.parent.parent.kind === ts.SyntaxKind.ForStatement)) { - return; - } - this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.POSTFIX_FAILURE_STRING)); +function isAllowedLocation(node: ts.Node): boolean { + switch (node.kind) { + // Can be a statement + case ts.SyntaxKind.ExpressionStatement: + return true; + + // Can be directly in a for-statement + case ts.SyntaxKind.ForStatement: + return true; + + // Can be in a comma operator in a for statement (`for (let a = 0, b = 10; a < b; a++, b--)`) + case ts.SyntaxKind.BinaryExpression: + return (node as ts.BinaryExpression).operatorToken.kind === ts.SyntaxKind.CommaToken && + node.parent!.kind === ts.SyntaxKind.ForStatement; + + default: + return false; } } diff --git a/scripts/tslint/noTypeAssertionWhitespaceRule.ts b/scripts/tslint/noTypeAssertionWhitespaceRule.ts index 5368dcf74ba..37017fb60e4 100644 --- a/scripts/tslint/noTypeAssertionWhitespaceRule.ts +++ b/scripts/tslint/noTypeAssertionWhitespaceRule.ts @@ -1,25 +1,25 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static TRAILING_FAILURE_STRING = "Excess trailing whitespace found around type assertion."; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new TypeAssertionWhitespaceWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class TypeAssertionWhitespaceWalker extends Lint.RuleWalker { - public visitNode(node: ts.Node) { +function walk(ctx: Lint.WalkContext): void { + ts.forEachChild(ctx.sourceFile, recur); + function recur(node: ts.Node) { if (node.kind === ts.SyntaxKind.TypeAssertionExpression) { const refined = node as ts.TypeAssertion; const leftSideWhitespaceStart = refined.type.getEnd() + 1; const rightSideWhitespaceEnd = refined.expression.getStart(); if (leftSideWhitespaceStart !== rightSideWhitespaceEnd) { - this.addFailure(this.createFailure(leftSideWhitespaceStart, rightSideWhitespaceEnd, Rule.TRAILING_FAILURE_STRING)); + ctx.addFailure(leftSideWhitespaceStart, rightSideWhitespaceEnd, Rule.TRAILING_FAILURE_STRING); } } - super.visitNode(node); + ts.forEachChild(node, recur); } } diff --git a/scripts/tslint/objectLiteralSurroundingSpaceRule.ts b/scripts/tslint/objectLiteralSurroundingSpaceRule.ts index a705e56c969..8546aa6c973 100644 --- a/scripts/tslint/objectLiteralSurroundingSpaceRule.ts +++ b/scripts/tslint/objectLiteralSurroundingSpaceRule.ts @@ -1,7 +1,6 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static LEADING_FAILURE_STRING = "No leading whitespace found on single-line object literal."; public static TRAILING_FAILURE_STRING = "No trailing whitespace found on single-line object literal."; @@ -9,34 +8,37 @@ export class Rule extends Lint.Rules.AbstractRule { public static TRAILING_EXCESS_FAILURE_STRING = "Excess trailing whitespace found on single-line object literal."; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new ObjectLiteralSpaceWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class ObjectLiteralSpaceWalker extends Lint.RuleWalker { - public visitNode(node: ts.Node) { +function walk(ctx: Lint.WalkContext): void { + const { sourceFile } = ctx; + ts.forEachChild(sourceFile, recur); + function recur(node: ts.Node): void { if (node.kind === ts.SyntaxKind.ObjectLiteralExpression) { - const literal = node as ts.ObjectLiteralExpression; - const text = literal.getText(); - if (text.match(/^{[^\n]+}$/g)) { - if (text.charAt(1) !== " ") { - const failure = this.createFailure(node.pos, node.getWidth(), Rule.LEADING_FAILURE_STRING); - this.addFailure(failure); - } - if (text.charAt(2) === " ") { - const failure = this.createFailure(node.pos + 2, 1, Rule.LEADING_EXCESS_FAILURE_STRING); - this.addFailure(failure); - } - if (text.charAt(text.length - 2) !== " ") { - const failure = this.createFailure(node.pos, node.getWidth(), Rule.TRAILING_FAILURE_STRING); - this.addFailure(failure); - } - if (text.charAt(text.length - 3) === " ") { - const failure = this.createFailure(node.pos + node.getWidth() - 3, 1, Rule.TRAILING_EXCESS_FAILURE_STRING); - this.addFailure(failure); - } - } + check(node as ts.ObjectLiteralExpression); + } + ts.forEachChild(node, recur); + } + + function check(node: ts.ObjectLiteralExpression): void { + const text = node.getText(sourceFile); + if (!text.match(/^{[^\n]+}$/g)) { + return; + } + + if (text.charAt(1) !== " ") { + ctx.addFailureAtNode(node, Rule.LEADING_FAILURE_STRING); + } + if (text.charAt(2) === " ") { + ctx.addFailureAt(node.pos + 2, 1, Rule.LEADING_EXCESS_FAILURE_STRING); + } + if (text.charAt(text.length - 2) !== " ") { + ctx.addFailureAtNode(node, Rule.TRAILING_FAILURE_STRING); + } + if (text.charAt(text.length - 3) === " ") { + ctx.addFailureAt(node.pos + node.getWidth() - 3, 1, Rule.TRAILING_EXCESS_FAILURE_STRING); } - super.visitNode(node); } } diff --git a/scripts/tslint/tsconfig.json b/scripts/tslint/tsconfig.json index db018ce2776..c9bf8dc01dc 100644 --- a/scripts/tslint/tsconfig.json +++ b/scripts/tslint/tsconfig.json @@ -1,6 +1,11 @@ { "compilerOptions": { "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, "module": "commonjs", "outDir": "../../built/local/tslint" } diff --git a/scripts/tslint/typeOperatorSpacingRule.ts b/scripts/tslint/typeOperatorSpacingRule.ts index 50f2971a0ee..4bd70e6eefa 100644 --- a/scripts/tslint/typeOperatorSpacingRule.ts +++ b/scripts/tslint/typeOperatorSpacingRule.ts @@ -1,34 +1,36 @@ import * as Lint from "tslint/lib"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static FAILURE_STRING = "The '|' and '&' operators must be surrounded by single spaces"; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { - return this.applyWithWalker(new TypeOperatorSpacingWalker(sourceFile, this.getOptions())); + return this.applyWithFunction(sourceFile, walk); } } -class TypeOperatorSpacingWalker extends Lint.RuleWalker { - public visitNode(node: ts.Node) { +function walk(ctx: Lint.WalkContext): void { + const { sourceFile } = ctx; + ts.forEachChild(sourceFile, recur); + function recur(node: ts.Node): void { if (node.kind === ts.SyntaxKind.UnionType || node.kind === ts.SyntaxKind.IntersectionType) { - const types = (node).types; - let expectedStart = types[0].end + 2; // space, | or & - for (let i = 1; i < types.length; i++) { - const currentType = types[i]; - if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) { - const sourceFile = currentType.getSourceFile(); - const previousTypeEndPos = sourceFile.getLineAndCharacterOfPosition(types[i - 1].end); - const currentTypeStartPos = sourceFile.getLineAndCharacterOfPosition(currentType.pos); - if (previousTypeEndPos.line === currentTypeStartPos.line) { - const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING); - this.addFailure(failure); - } + check((node as ts.UnionOrIntersectionTypeNode).types); + } + ts.forEachChild(node, recur); + } + + function check(types: ts.TypeNode[]): void { + let expectedStart = types[0].end + 2; // space, | or & + for (let i = 1; i < types.length; i++) { + const currentType = types[i]; + if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) { + const previousTypeEndPos = sourceFile.getLineAndCharacterOfPosition(types[i - 1].end); + const currentTypeStartPos = sourceFile.getLineAndCharacterOfPosition(currentType.pos); + if (previousTypeEndPos.line === currentTypeStartPos.line) { + ctx.addFailureAtNode(currentType, Rule.FAILURE_STRING); } - expectedStart = currentType.end + 2; } + expectedStart = currentType.end + 2; } - super.visitNode(node); } } diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7e8a99343bd..af322c53726 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1903,7 +1903,7 @@ namespace ts { // Even though in the AST the jsdoc @typedef node belongs to the current node, // its symbol might be in the same scope with the current node's symbol. Consider: - // + // // /** @typedef {string | number} MyType */ // function foo(); // diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 48baef4494c..8f2c32721f7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6b4e9ff590e..8631621ff7b 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 71c0f55c9af..5550e2f62c2 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ee224befd45..70557ea4374 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index cfafaabebff..3ff3bc2782f 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index cf50ab6482b..2a15df80102 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1,4 +1,4 @@ -/// +/// declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index b9a75015f41..df87b17955b 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 57e85f50f39..e55cfc76db3 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -1,4 +1,4 @@ -/// +/// /// // Transforms generator functions into a compatible ES5 representation with similar runtime diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 72a3558b1a3..0240ddf38fe 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 7488c51ed91..1a362c47fd1 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index e712393b2f0..70e141d8559 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index b1ffcff43a4..32b6a90e268 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index df851eb07df..142ab9767c4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { /** * Type of objects whose values are all of the same type. * The `in` and `for-in` operators can *not* be safely used, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2ab2fc2fc23..60d8d784d96 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1,4 +1,4 @@ -/// +/// /* @internal */ namespace ts { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 2d75d646128..0f4a4ed6561 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 49d1336c874..28c59d717c0 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1,4 +1,4 @@ -// +// // Copyright (c) Microsoft Corporation. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index caeab18958e..5ea45d2a5f6 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts { interface File { diff --git a/src/harness/unittests/initializeTSConfig.ts b/src/harness/unittests/initializeTSConfig.ts index cb995212a94..ab9aaea0001 100644 --- a/src/harness/unittests/initializeTSConfig.ts +++ b/src/harness/unittests/initializeTSConfig.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index d13dd7a26fa..c9ecef0de44 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/harness/unittests/services/colorization.ts b/src/harness/unittests/services/colorization.ts index 70592ea4151..fd7d932885a 100644 --- a/src/harness/unittests/services/colorization.ts +++ b/src/harness/unittests/services/colorization.ts @@ -1,4 +1,4 @@ -/// +/// interface ClassificationEntry { value: any; diff --git a/src/harness/unittests/services/preProcessFile.ts b/src/harness/unittests/services/preProcessFile.ts index 403cccc8cf3..b7d319a690f 100644 --- a/src/harness/unittests/services/preProcessFile.ts +++ b/src/harness/unittests/services/preProcessFile.ts @@ -1,4 +1,4 @@ -/// +/// describe("PreProcessFile:", function () { function test(sourceText: string, readImportFile: boolean, detectJavaScriptImports: boolean, expectedPreProcess: ts.PreProcessedFileInfo): void { diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 8d306a6099b..d3ea153e235 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -1,4 +1,4 @@ -/// +/// const expect: typeof _chai.expect = _chai.expect; diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 7446cc84deb..e356b52da6f 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.projectSystem { diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 29076df80f2..7fa22c29c16 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/server/cancellationToken/cancellationToken.ts b/src/server/cancellationToken/cancellationToken.ts index 71a31d14016..0e7969c1e45 100644 --- a/src/server/cancellationToken/cancellationToken.ts +++ b/src/server/cancellationToken/cancellationToken.ts @@ -37,7 +37,7 @@ function createCancellationToken(args: string[]): ServerCancellationToken { // when client wants to signal cancellation it should create a named pipe with name= // server will synchronously check the presence of the pipe and treat its existance as indicator that current request should be canceled. // in case if client prefers to use more fine-grained schema than one name for all request it can add '*' to the end of cancelellationPipeName. - // in this case pipe name will be build dynamically as . + // in this case pipe name will be build dynamically as . if (cancellationPipeName.charAt(cancellationPipeName.length - 1) === "*") { const namePrefix = cancellationPipeName.slice(0, -1); if (namePrefix.length === 0 || namePrefix.indexOf("*") >= 0) { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index d0535e2f528..d1bc57ee970 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/server/project.ts b/src/server/project.ts index e4669ea191b..7125acb2c5f 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/server/session.ts b/src/server/session.ts index f1b373c4a90..f25fdb9c98f 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -226,7 +226,7 @@ namespace ts.server { /** * Represents operation that can schedule its next step to be executed later. - * Scheduling is done via instance of NextStep. If on current step subsequent step was not scheduled - operation is assumed to be completed. + * Scheduling is done via instance of NextStep. If on current step subsequent step was not scheduled - operation is assumed to be completed. */ class MultistepOperation { private requestId: number; diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index ff20e89e2d7..602a849b5cd 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.server.typingsInstaller { diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index e889f98789a..fa533450b26 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index 10d0b8eef34..c22ba779d19 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts { export interface CodeFix { errorCodes: number[]; diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 1f1b499d03b..a5394c17cdd 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.codefix { type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport"; diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index a45a3c26dba..61d48bdc3bc 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.codefix { registerCodeFix({ errorCodes: [ diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index 80b0133ccfe..e2cd20a4463 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { /** * The document registry represents a store of SourceFile objects that can be shared between * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 24d7d648272..8576f48f6e3 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.FindAllReferences { export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean, isForRename: boolean): ReferencedSymbol[] | undefined { const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index b732d8a1193..f2602903be3 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.GoToDefinition { export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[] { /// Triple slash reference comments diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 08a51a63e63..de2481b8784 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.JsDoc { const jsDocTagNames = [ "augments", diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 248ceef1bd3..e7196e8f491 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. +// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. /// diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 05ccbcc71f4..2c8d43b535b 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.NavigateTo { type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; diff --git a/src/services/services.ts b/src/services/services.ts index f122e39bcc6..df5330ebaed 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/services/transpile.ts b/src/services/transpile.ts index 86c6a3e8904..89ddb887809 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { export interface TranspileOptions { compilerOptions?: CompilerOptions; fileName?: string; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index a4f574b9c28..7c5bf862fc8 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1,4 +1,4 @@ -// These utilities are common to multiple language service features. +// These utilities are common to multiple language service features. /* @internal */ namespace ts { export const scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true); diff --git a/tslint.json b/tslint.json index 13de7acec63..37f64a05159 100644 --- a/tslint.json +++ b/tslint.json @@ -1,5 +1,6 @@ { "rules": { + "no-bom": true, "class-name": true, "comment-format": [true, "check-space" From d878f80f90cc5376ec1f1198055d0e8634cf7f56 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Mar 2017 11:23:49 -0800 Subject: [PATCH 079/167] more rigorous implements-clause check --- src/compiler/utilities.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9eb76405031..37fb48bef05 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3126,8 +3126,9 @@ namespace ts { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } - export function isExpressionWithTypeArgumentsInClassImplementsClause(node: Node): boolean { + export function isExpressionWithTypeArgumentsInClassImplementsClause(node: Node): node is ExpressionWithTypeArguments { return node.kind === SyntaxKind.ExpressionWithTypeArguments + && isEntityNameExpression((node as ExpressionWithTypeArguments).expression) && node.parent && (node.parent).token === SyntaxKind.ImplementsKeyword && node.parent.parent From 0261586d6e4384fbae32ccec76089c6bb1c79f2f Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Mar 2017 11:27:59 -0800 Subject: [PATCH 080/167] cleanup --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9698f0cf4f0..d1990d03ac3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21125,8 +21125,8 @@ namespace ts { // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the // extends clause of a class. We handle that case here. const classNode = getContainingClass(node); - const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)) as InterfaceType; classType; - const baseType = getBaseTypes(classType)[0]; baseType; + const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)) as InterfaceType; + const baseType = getBaseTypes(classType)[0]; return baseType && getTypeWithThisArgument(baseType, classType.thisType); } From 7561cdf6bf3b9187f6fdfc704f8f867615fd1d59 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 1 Mar 2017 17:16:09 -0800 Subject: [PATCH 081/167] Add ThisType to Object.{create|defineProperty|defineProperties} --- src/lib/es5.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 711981888a9..04743f7d77f 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -147,7 +147,7 @@ interface ObjectConstructor { * @param o Object to use as a prototype. May be null * @param properties JavaScript object that contains one or more property descriptors. */ - create(o: object | null, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap & ThisType): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -155,14 +155,14 @@ interface ObjectConstructor { * @param p The property name. * @param attributes Descriptor for the property. It can be for a data property or an accessor property. */ - defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + defineProperty(o: any, p: string, attributes: PropertyDescriptor & ThisType): any; /** * Adds one or more properties to an object, and/or modifies attributes of existing properties. * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. */ - defineProperties(o: any, properties: PropertyDescriptorMap): any; + defineProperties(o: any, properties: PropertyDescriptorMap & ThisType): any; /** * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. From 258bb4ff55f0336ac4df67056296eca23eaf783b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 1 Mar 2017 17:16:35 -0800 Subject: [PATCH 082/167] Accept new baselines --- .../reference/getterSetterNonAccessor.types | 4 +- tests/baselines/reference/objectCreate.types | 40 +++++++++---------- tests/baselines/reference/objectCreate2.types | 40 +++++++++---------- .../reference/objectLitGetterSetter.types | 4 +- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/tests/baselines/reference/getterSetterNonAccessor.types b/tests/baselines/reference/getterSetterNonAccessor.types index f5eb22296f3..4fbff67ee49 100644 --- a/tests/baselines/reference/getterSetterNonAccessor.types +++ b/tests/baselines/reference/getterSetterNonAccessor.types @@ -9,9 +9,9 @@ function setFunc(v){} Object.defineProperty({}, "0", ({ >Object.defineProperty({}, "0", ({ get: getFunc, set: setFunc, configurable: true })) : any ->Object.defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any +>Object.defineProperty : (o: any, p: string, attributes: PropertyDescriptor & ThisType) => any >Object : ObjectConstructor ->defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any +>defineProperty : (o: any, p: string, attributes: PropertyDescriptor & ThisType) => any >{} : {} >"0" : "0" >({ get: getFunc, set: setFunc, configurable: true }) : PropertyDescriptor diff --git a/tests/baselines/reference/objectCreate.types b/tests/baselines/reference/objectCreate.types index b4e0e72061e..8bf433e53fe 100644 --- a/tests/baselines/reference/objectCreate.types +++ b/tests/baselines/reference/objectCreate.types @@ -9,17 +9,17 @@ declare var union: null | { a: number, b: string }; var n = Object.create(null); // object >n : any >Object.create(null) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >null : null var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } >t : any >Object.create({ a: 1, b: "" }) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >{ a: 1, b: "" } : { a: number; b: string; } >a : number >1 : 1 @@ -29,43 +29,43 @@ var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } var u = Object.create(union); // object | {a: number, b: string } >u : any >Object.create(union) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >union : { a: number; b: string; } | null var e = Object.create({}); // {} >e : any >Object.create({}) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >{} : {} var o = Object.create({}); // object >o : any >Object.create({}) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >{} : object >{} : {} var a = Object.create(null, {}); // any >a : any >Object.create(null, {}) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >null : null >{} : {} var a = Object.create({ a: 1, b: "" }, {}); >a : any >Object.create({ a: 1, b: "" }, {}) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >{ a: 1, b: "" } : { a: number; b: string; } >a : number >1 : 1 @@ -76,27 +76,27 @@ var a = Object.create({ a: 1, b: "" }, {}); var a = Object.create(union, {}); >a : any >Object.create(union, {}) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >union : { a: number; b: string; } | null >{} : {} var a = Object.create({}, {}); >a : any >Object.create({}, {}) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >{} : {} >{} : {} var a = Object.create({}, {}); >a : any >Object.create({}, {}) : any ->Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap & ThisType): any; } >{} : object >{} : {} >{} : {} diff --git a/tests/baselines/reference/objectCreate2.types b/tests/baselines/reference/objectCreate2.types index 3e19c08bfc0..1602d70d571 100644 --- a/tests/baselines/reference/objectCreate2.types +++ b/tests/baselines/reference/objectCreate2.types @@ -9,17 +9,17 @@ declare var union: null | { a: number, b: string }; var n = Object.create(null); // any >n : any >Object.create(null) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >null : null var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } >t : any >Object.create({ a: 1, b: "" }) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >{ a: 1, b: "" } : { a: number; b: string; } >a : number >1 : 1 @@ -29,43 +29,43 @@ var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } var u = Object.create(union); // {a: number, b: string } >u : any >Object.create(union) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >union : { a: number; b: string; } var e = Object.create({}); // {} >e : any >Object.create({}) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >{} : {} var o = Object.create({}); // object >o : any >Object.create({}) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >{} : object >{} : {} var a = Object.create(null, {}); // any >a : any >Object.create(null, {}) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >null : null >{} : {} var a = Object.create({ a: 1, b: "" }, {}); >a : any >Object.create({ a: 1, b: "" }, {}) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >{ a: 1, b: "" } : { a: number; b: string; } >a : number >1 : 1 @@ -76,27 +76,27 @@ var a = Object.create({ a: 1, b: "" }, {}); var a = Object.create(union, {}); >a : any >Object.create(union, {}) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >union : { a: number; b: string; } >{} : {} var a = Object.create({}, {}); >a : any >Object.create({}, {}) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >{} : {} >{} : {} var a = Object.create({}, {}); >a : any >Object.create({}, {}) : any ->Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >Object : ObjectConstructor ->create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } >{} : object >{} : {} >{} : {} diff --git a/tests/baselines/reference/objectLitGetterSetter.types b/tests/baselines/reference/objectLitGetterSetter.types index 12801b65340..c2ce173e029 100644 --- a/tests/baselines/reference/objectLitGetterSetter.types +++ b/tests/baselines/reference/objectLitGetterSetter.types @@ -5,9 +5,9 @@ Object.defineProperty(obj, "accProperty", ({ >Object.defineProperty(obj, "accProperty", ({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } })) : any ->Object.defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any +>Object.defineProperty : (o: any, p: string, attributes: PropertyDescriptor & ThisType) => any >Object : ObjectConstructor ->defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any +>defineProperty : (o: any, p: string, attributes: PropertyDescriptor & ThisType) => any >obj : {} >"accProperty" : "accProperty" >({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } }) : PropertyDescriptor From b5c6221e36c1e4d20300b07ebefcdcab9121b57c Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 1 Mar 2017 17:46:35 -0800 Subject: [PATCH 083/167] Address PR --- src/services/completions.ts | 56 +++++++++++++++++++++++-------------- src/services/jsDoc.ts | 43 ++++++++++++++-------------- 2 files changed, 56 insertions(+), 43 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index 1d446f0aa59..042312c1240 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -16,11 +16,16 @@ namespace ts.Completions { return undefined; } - const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName } = completionData; + const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, requestJsDocTagName, requestJsDocTag } = completionData; - if (isJsDocTagName) { + if (requestJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getAllJsDocCompletionEntries(shouldAppendAtSignBeforeJsDocTagName) }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getJSDocTagNameCompletions() }; + } + + if (requestJsDocTag) { + // If the current position is a jsDoc tag, only tags should be provided for completion + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getJSDocTagCompletions() }; } const entries: CompletionEntry[] = []; @@ -54,7 +59,7 @@ namespace ts.Completions { } // Add keywords if this is not a member completion list - if (!isMemberCompletion && !isJsDocTagName) { + if (!isMemberCompletion && !(requestJsDocTag && requestJsDocTagName)) { addRange(entries, keywordCompletions); } @@ -814,13 +819,10 @@ namespace ts.Completions { function getCompletionData(typeChecker: TypeChecker, log: (message: string) => void, sourceFile: SourceFile, position: number) { const isJavaScriptFile = isSourceFileJavaScript(sourceFile); - let isJsDocTagName = false; - // This is for the case when users request completion in JsDoc without "@" - // i.e. - // /** - // * |completion here| - // **/ - let shouldAppendAtSignBeforeJsDocTagName = false; + // JsDoc tag-name is just the name of the JSDoc tagname (exclude "@") + let requestJsDocTagName = false; + // JsDoc tag includes both "@" and tag-name + let requestJsDocTag = false; let start = timestamp(); const currentToken = getTokenAtPosition(sourceFile, position); @@ -836,15 +838,27 @@ namespace ts.Completions { // The current position is next to the '@' sign, when no tag name being provided yet. // Provide a full list of tag names if (sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) { - isJsDocTagName = true; + requestJsDocTagName = true; } else { + // When completion is requested without "@", we will have check to make sure that + // there are no comments prefix the request position. We will only allow "*" and space. + // e.g + // /** |c| /* + // + // /** + // |c| + // */ + // + // /** + // * |c| + // */ + // + // /** + // * |c| + // */ const lineStart = getLineStartPositionForPosition(position, sourceFile); - shouldAppendAtSignBeforeJsDocTagName = sourceFile.text.substr(lineStart, position).indexOf("@") === -1; - - if (shouldAppendAtSignBeforeJsDocTagName) { - isJsDocTagName = true; - } + requestJsDocTag = !(sourceFile.text.substr(lineStart, position).match(/[^\*|\s|(/\*\*)]/)); } } @@ -855,7 +869,7 @@ namespace ts.Completions { const tag = getJsDocTagAtPosition(sourceFile, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; + requestJsDocTagName = true; } switch (tag.kind) { @@ -870,8 +884,8 @@ namespace ts.Completions { } } - if (isJsDocTagName || shouldAppendAtSignBeforeJsDocTagName) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName }; + if (requestJsDocTagName || requestJsDocTag) { + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName, requestJsDocTag }; } if (!insideJsDocTagExpression) { @@ -999,7 +1013,7 @@ namespace ts.Completions { log("getCompletionData: Semantic work: " + (timestamp() - semanticStart)); - return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName }; + return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName, requestJsDocTag }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 40ee276b0fa..59c6ad4b03b 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -43,7 +43,7 @@ namespace ts.JsDoc { "version" ]; let jsDocTagNameCompletionEntries: CompletionEntry[]; - let jsDocTagNameWithAtSignCompletionEntries: CompletionEntry[]; + let jsDocTagCompletionEntries: CompletionEntry[]; export function getJsDocCommentsFromDeclarations(declarations: Declaration[]) { // Only collect doc comments from duplicate declarations once: @@ -89,27 +89,26 @@ namespace ts.JsDoc { return undefined; } - export function getAllJsDocCompletionEntries(shouldAppendAtSign: boolean): CompletionEntry[] { - if (!shouldAppendAtSign) { - return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, tagName => { - return { - name: tagName, - kind: ScriptElementKind.keyword, - kindModifiers: "", - sortText: "0", - }; - })); - } - else { - return jsDocTagNameWithAtSignCompletionEntries || (jsDocTagNameWithAtSignCompletionEntries = ts.map(jsDocTagNames, tagName => { - return { - name: `@${tagName}`, - kind: ScriptElementKind.keyword, - kindModifiers: "", - sortText: "0" - } - })); - } + export function getJSDocTagNameCompletions(): CompletionEntry[] { + return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, tagName => { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0", + }; + })); + } + + export function getJSDocTagCompletions(): CompletionEntry[] { + return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, tagName => { + return { + name: `@${tagName}`, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + } + })); } /** From 34b68095d213ed14a718afbb3074f73576d70189 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 1 Mar 2017 17:46:46 -0800 Subject: [PATCH 084/167] Add more tests --- tests/cases/fourslash/completionInJsDoc.ts | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts index cf8a448bf19..3fd92f42d52 100644 --- a/tests/cases/fourslash/completionInJsDoc.ts +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -36,6 +36,22 @@ //// * /*11*/ //// */ +//// /** +//// /*12*/ +//// */ + +//// /** +//// * /*13*/ +//// */ + +//// /** +//// * some comment /*14*/ +//// */ + +//// /** +//// * @param /*15*/ +//// */ + goTo.marker('1'); verify.completionListContains("constructor"); verify.completionListContains("param"); @@ -76,3 +92,17 @@ verify.completionListContains("@returns"); goTo.marker('11'); verify.completionListCount(40); verify.completionListContains("@argument"); + +goTo.marker('12'); +verify.completionListCount(40); +verify.completionListContains("@constructor"); + +goTo.marker('13'); +verify.completionListCount(40); +verify.completionListContains("@param"); + +goTo.marker('14'); +verify.completionListIsEmpty(); + +goTo.marker('15'); +verify.completionListIsEmpty(); \ No newline at end of file From da51f396955ffa416e37e985fc33f4cf35aebfe6 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 1 Mar 2017 21:11:34 -0800 Subject: [PATCH 085/167] FIx minor stuffs --- src/services/completions.ts | 4 ++-- tests/cases/fourslash/completionInJsDoc.ts | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index 042312c1240..6a4ee3485de 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -59,7 +59,7 @@ namespace ts.Completions { } // Add keywords if this is not a member completion list - if (!isMemberCompletion && !(requestJsDocTag && requestJsDocTagName)) { + if (!isMemberCompletion && !requestJsDocTag && !requestJsDocTagName) { addRange(entries, keywordCompletions); } @@ -858,7 +858,7 @@ namespace ts.Completions { // * |c| // */ const lineStart = getLineStartPositionForPosition(position, sourceFile); - requestJsDocTag = !(sourceFile.text.substr(lineStart, position).match(/[^\*|\s|(/\*\*)]/)); + requestJsDocTag = !(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/)); } } diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts index 3fd92f42d52..60707905956 100644 --- a/tests/cases/fourslash/completionInJsDoc.ts +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -35,22 +35,24 @@ //// /** //// * /*11*/ //// */ - +//// //// /** //// /*12*/ //// */ - +//// //// /** //// * /*13*/ //// */ - +//// //// /** //// * some comment /*14*/ //// */ - +//// //// /** //// * @param /*15*/ //// */ +//// +//// /** @param /*16*/ */ goTo.marker('1'); verify.completionListContains("constructor"); @@ -105,4 +107,7 @@ goTo.marker('14'); verify.completionListIsEmpty(); goTo.marker('15'); +verify.completionListIsEmpty(); + +goTo.marker('16'); verify.completionListIsEmpty(); \ No newline at end of file From 3bc125463b96314702a9b4b20ae58e63a0030e62 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 3 Mar 2017 07:00:52 -0800 Subject: [PATCH 086/167] Add more missing semicolons --- src/compiler/checker.ts | 2 +- src/compiler/declarationEmitter.ts | 2 +- src/compiler/moduleNameResolver.ts | 2 +- src/compiler/transformer.ts | 4 ++-- src/compiler/transformers/module/module.ts | 2 +- src/compiler/types.ts | 2 +- src/harness/fourslash.ts | 4 ++-- src/harness/harness.ts | 2 +- src/harness/harnessLanguageService.ts | 2 +- src/harness/unittests/tsserverProjectSystem.ts | 8 ++++---- src/server/server.ts | 2 +- src/server/session.ts | 10 +++++----- src/server/watchGuard/watchGuard.ts | 2 +- src/services/jsDoc.ts | 2 +- 14 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 45ccdae1b41..c189475fd4d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -141,7 +141,7 @@ namespace ts { getAugmentedPropertiesOfType, getRootSymbols, getContextualType: node => { - node = getParseTreeNode(node, isExpression) + node = getParseTreeNode(node, isExpression); return node ? getContextualType(node) : undefined; }, getFullyQualifiedName, diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 12411cabd56..4a542ab30c7 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -1164,7 +1164,7 @@ namespace ts { emitTypeParameters(node.typeParameters); const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - node.name + node.name; emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false); } emitHeritageClause(node.name, getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 5bdc4621a34..1911605a0a6 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -675,7 +675,7 @@ namespace ts { } export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations { - return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false); + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /*jsOnly*/ false); } /* @internal */ diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index b9a75015f41..d51fdb12ac3 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -121,13 +121,13 @@ namespace ts { enableEmitNotification, isSubstitutionEnabled, isEmitNotificationEnabled, - get onSubstituteNode() { return onSubstituteNode }, + get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed."); Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, - get onEmitNode() { return onEmitNode }, + get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed."); Debug.assert(value !== undefined, "Value must not be 'undefined'"); diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 72a3558b1a3..52c6db707c1 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1152,7 +1152,7 @@ namespace ts { createIdentifier("__esModule"), createLiteral(true) ) - ) + ); } else { statement = createStatement( diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4ffd44e6aa1..53d84118609 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3297,7 +3297,7 @@ } export interface PluginImport { - name: string + name: string; } export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 77c58b8d8b7..2532a1875d9 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2136,7 +2136,7 @@ namespace FourSlash { const result = includeWhiteSpace ? actualText === expectedText - : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText) + : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText); if (!result) { this.raiseError(`Actual text doesn't match expected text. Actual:\n'${actualText}'\nExpected:\n'${expectedText}'`); @@ -2173,7 +2173,7 @@ namespace FourSlash { start: diagnostic.start, length: diagnostic.length, code: diagnostic.code - } + }; }); const dedupedDiagnositcs = ts.deduplicate(diagnosticsForCodeFix, ts.equalOwnProperties); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 3d9b64bd30c..23e8106864a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1017,7 +1017,7 @@ namespace Harness { } else { if (!es6TestLibFileNameSourceFileMap.get(libFileName)) { - es6TestLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget)) + es6TestLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget)); } } } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 202b429fcbc..e7f32748570 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -779,7 +779,7 @@ namespace Harness.LanguageService { start: 0 }); return prev; - } + }; return proxy; } }), diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index d7e39652ed8..1531b18bb9d 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3307,12 +3307,12 @@ namespace ts.projectSystem { isCancellationRequested: () => false, setRequest: requestId => { if (expectedRequestId === undefined) { - assert.isTrue(false, "unexpected call") + assert.isTrue(false, "unexpected call"); } assert.equal(requestId, expectedRequestId); }, resetRequest: noop - } + }; const session = createSession(host, /*typingsInstaller*/ undefined, /*projectServiceEventHandler*/ undefined, cancellationToken); expectedRequestId = session.getNextSeq(); @@ -3359,13 +3359,13 @@ namespace ts.projectSystem { currentId = requestId; }, resetRequest(requestId) { - assert.equal(requestId, currentId, "unexpected request id in cancellation") + assert.equal(requestId, currentId, "unexpected request id in cancellation"); currentId = undefined; }, isCancellationRequested() { return requestToCancel === currentId; } - } + }; })(); const host = createServerHost([f1, config]); const session = createSession(host, /*typingsInstaller*/ undefined, () => {}, cancellationToken); diff --git a/src/server/server.ts b/src/server/server.ts index 3badc2c2b50..2c68963ec5c 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -653,7 +653,7 @@ namespace ts.server { // this drive is unsafe - return no-op watcher return { close() { } }; } - } + }; } // Override sys.write because fs.writeSync is not reliable on Node 4 diff --git a/src/server/session.ts b/src/server/session.ts index f1b373c4a90..b5e7e44970d 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -226,7 +226,7 @@ namespace ts.server { /** * Represents operation that can schedule its next step to be executed later. - * Scheduling is done via instance of NextStep. If on current step subsequent step was not scheduled - operation is assumed to be completed. + * Scheduling is done via instance of NextStep. If on current step subsequent step was not scheduled - operation is assumed to be completed. */ class MultistepOperation { private requestId: number; @@ -239,7 +239,7 @@ namespace ts.server { this.next = { immediate: action => this.immediate(action), delay: (ms, action) => this.delay(ms, action) - } + }; } public startNew(action: (next: NextStep) => void) { @@ -262,7 +262,7 @@ namespace ts.server { private immediate(action: () => void) { const requestId = this.requestId; - Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id") + Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id"); this.setImmediateId(this.operationHost.getServerHost().setImmediate(() => { this.immediateId = undefined; this.operationHost.executeWithRequestId(requestId, () => this.executeAction(action)); @@ -271,7 +271,7 @@ namespace ts.server { private delay(ms: number, action: () => void) { const requestId = this.requestId; - Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id") + Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id"); this.setTimerHandle(this.operationHost.getServerHost().setTimeout(() => { this.timerHandle = undefined; this.operationHost.executeWithRequestId(requestId, () => this.executeAction(action)); @@ -351,7 +351,7 @@ namespace ts.server { logError: (err, cmd) => this.logError(err, cmd), sendRequestCompletedEvent: requestId => this.sendRequestCompletedEvent(requestId), isCancellationRequested: () => cancellationToken.isCancellationRequested() - } + }; this.errorCheck = new MultistepOperation(multistepOperationHost); this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); this.gcTimer = new GcTimer(host, /*delay*/ 7000, logger); diff --git a/src/server/watchGuard/watchGuard.ts b/src/server/watchGuard/watchGuard.ts index 7a0307a9120..f57369aecb9 100644 --- a/src/server/watchGuard/watchGuard.ts +++ b/src/server/watchGuard/watchGuard.ts @@ -11,7 +11,7 @@ const fs: { watch(directoryName: string, options: any, callback: () => {}): any // This means that here we treat any result (success or exception) from fs.watch as success since it does not tear down the process. // The only case that should be considered as failure - when watchGuard process crashes. try { - const watcher = fs.watch(directoryName, { recursive: true }, () => ({})) + const watcher = fs.watch(directoryName, { recursive: true }, () => ({})); watcher.close(); } catch (_e) { diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 59c6ad4b03b..a2a32f95fa4 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -107,7 +107,7 @@ namespace ts.JsDoc { kind: ScriptElementKind.keyword, kindModifiers: "", sortText: "0" - } + }; })); } From b2f7d4797762412e57e58798ad5ccadeac748e8e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 3 Mar 2017 08:54:41 -0800 Subject: [PATCH 087/167] Remove old commented-out code --- tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts b/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts index 0bc3c1ab89b..14c7b3caf1c 100644 --- a/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts +++ b/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts @@ -19,6 +19,4 @@ /////*25*/eInstance1 = /*26*/constE./*27*/e2; /////*28*/eInstance1 = /*29*/constE./*30*/e3; -//goTo.marker("2"); -//verify.verifyQuickInfoDisplayParts("enum member", "", { start: 0, length: 2 }, /*displayParts*/[], /*documentation*/[]); verify.baselineQuickInfo(); From cda741d14a7e7339a361dc8d1aa8680533f80ebd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 3 Mar 2017 10:25:10 -0800 Subject: [PATCH 088/167] Introduce --strict compiler option --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 40 +++++++++++++++------------- src/compiler/commandLineParser.ts | 7 ++++- src/compiler/diagnosticMessages.json | 4 +++ src/compiler/program.ts | 2 +- src/compiler/transformers/ts.ts | 3 ++- src/compiler/types.ts | 9 ++++--- 7 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7e8a99343bd..ef00a3aecde 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -182,7 +182,7 @@ namespace ts { return bindSourceFile; function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean { - if (opts.alwaysStrict && !isDeclarationFile(file)) { + if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !isDeclarationFile(file)) { // bind in strict mode source files with alwaysStrict option return true; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9cd5b7a31d2..7b1a11e5300 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -56,7 +56,9 @@ namespace ts { const modulekind = getEmitModuleKind(compilerOptions); const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System; - const strictNullChecks = compilerOptions.strictNullChecks; + const strictNullChecks = compilerOptions.strictNullChecks === undefined ? compilerOptions.strict : compilerOptions.strictNullChecks; + const noImplicitAny = compilerOptions.noImplicitAny === undefined ? compilerOptions.strict : compilerOptions.noImplicitAny; + const noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; const emitResolver = createResolver(); @@ -1564,7 +1566,7 @@ namespace ts { error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); return undefined; } - else if (compilerOptions.noImplicitAny && moduleNotFoundError) { + else if (noImplicitAny && moduleNotFoundError) { error(errorNode, Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, @@ -3407,7 +3409,7 @@ namespace ts { return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) && + if ((noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) && declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) && !(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, @@ -3509,7 +3511,7 @@ namespace ts { if (isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); } - if (reportErrors && compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { + if (reportErrors && noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAnyError(element, anyType); } return anyType; @@ -3607,7 +3609,7 @@ namespace ts { type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration - if (reportErrors && compilerOptions.noImplicitAny) { + if (reportErrors && noImplicitAny) { if (!declarationBelongsToPrivateAmbientMember(declaration)) { reportImplicitAnyError(declaration, type); } @@ -3726,7 +3728,7 @@ namespace ts { } // Otherwise, fall back to 'any'. else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { if (setter) { error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } @@ -3741,7 +3743,7 @@ namespace ts { } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); error(getter, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } @@ -3824,7 +3826,7 @@ namespace ts { return unknownType; } // Otherwise variable has initializer that circularly references the variable itself - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } @@ -5585,7 +5587,7 @@ namespace ts { } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { const declaration = signature.declaration; if (declaration.name) { error(declaration.name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, declarationNameToString(declaration.name)); @@ -6540,7 +6542,7 @@ namespace ts { return indexInfo.type; } if (accessExpression && !isConstEnumObjectType(objectType)) { - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(objectType, IndexKind.Number)) { error(accessExpression.argumentExpression, Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } @@ -9126,7 +9128,7 @@ namespace ts { } function reportErrorsFromWidening(declaration: Declaration, type: Type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & TypeFlags.ContainsWideningType) { + if (produceDiagnostics && noImplicitAny && type.flags & TypeFlags.ContainsWideningType) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -11007,7 +11009,7 @@ namespace ts { // control flow based type does include undefined. if (type === autoType || type === autoArrayType) { if (flowType === autoType || flowType === autoArrayType) { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } @@ -11277,7 +11279,7 @@ namespace ts { } } - if (compilerOptions.noImplicitThis) { + if (noImplicitThis) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' error(node, Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); } @@ -12531,7 +12533,7 @@ namespace ts { return links.resolvedSymbol = unknownSymbol; } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(node, Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } return links.resolvedSymbol = unknownSymbol; @@ -12919,7 +12921,7 @@ namespace ts { } if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } } @@ -14742,7 +14744,7 @@ namespace ts { if (funcSymbol && funcSymbol.members && funcSymbol.flags & SymbolFlags.Function) { return getInferredClassType(funcSymbol); } - else if (compilerOptions.noImplicitAny) { + else if (noImplicitAny) { error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -15002,7 +15004,7 @@ namespace ts { const iterableIteratorAny = functionFlags & FunctionFlags.Async ? createAsyncIterableIteratorType(anyType) // AsyncGenerator function : createIterableIteratorType(anyType); // Generator function - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(func.asteriskToken, Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); } @@ -16544,7 +16546,7 @@ namespace ts { if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { + if (noImplicitAny && !node.type) { switch (node.kind) { case SyntaxKind.ConstructSignature: error(node, Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); @@ -17856,7 +17858,7 @@ namespace ts { if (produceDiagnostics && !node.type) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method // in an ambient context - if (compilerOptions.noImplicitAny && nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + if (noImplicitAny && nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { reportImplicitAnyError(node, anyType); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6b4e9ff590e..17bbbcb8a56 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -467,6 +467,11 @@ namespace ts { type: "boolean", description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, + { + name: "strict", + type: "boolean", + description: Diagnostics.Enable_all_strict_type_checks + }, { // A list of plugins to load in the language service name: "plugins", @@ -520,7 +525,7 @@ namespace ts { export const defaultInitCompilerOptions: CompilerOptions = { module: ModuleKind.CommonJS, target: ScriptTarget.ES5, - noImplicitAny: false, + strict: false, sourceMap: false, }; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 75aa5d25f72..318f06ceeaa 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3045,6 +3045,10 @@ "category": "Message", "code": 6149 }, + "Enable all strict type checks.": { + "category": "Message", + "code": 6150 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index eb9f0f0e0a1..d9ddf486e0d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1630,7 +1630,7 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } - if (options.noImplicitUseStrict && options.alwaysStrict) { + if (options.noImplicitUseStrict && (options.alwaysStrict === undefined ? options.strict : options.alwaysStrict)) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index e712393b2f0..b3696c31153 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -472,7 +472,8 @@ namespace ts { } function visitSourceFile(node: SourceFile) { - const alwaysStrict = compilerOptions.alwaysStrict && !(isExternalModule(node) && moduleKind === ModuleKind.ES2015); + const alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && + !(isExternalModule(node) && moduleKind === ModuleKind.ES2015); return updateSourceFileNode( node, visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4ffd44e6aa1..d9134cca091 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3308,7 +3308,7 @@ allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; - alwaysStrict?: boolean; + alwaysStrict?: boolean; // Always combine with strict property baseUrl?: string; charset?: string; /* @internal */ configFilePath?: string; @@ -3344,9 +3344,9 @@ noEmitOnError?: boolean; noErrorTruncation?: boolean; noFallthroughCasesInSwitch?: boolean; - noImplicitAny?: boolean; + noImplicitAny?: boolean; // Always combine with strict property noImplicitReturns?: boolean; - noImplicitThis?: boolean; + noImplicitThis?: boolean; // Always combine with strict property noUnusedLocals?: boolean; noUnusedParameters?: boolean; noImplicitUseStrict?: boolean; @@ -3369,7 +3369,8 @@ skipDefaultLibCheck?: boolean; sourceMap?: boolean; sourceRoot?: string; - strictNullChecks?: boolean; + strict?: boolean; + strictNullChecks?: boolean; // Always combine with strict property /* @internal */ stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; From 65cea207dad1eb593fcc47454e29cc0735949687 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 3 Mar 2017 14:32:18 -0800 Subject: [PATCH 089/167] Use getTypeOfExpression when inferring variable type from initializer --- src/compiler/checker.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c189475fd4d..a4c0acc405d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16131,7 +16131,7 @@ namespace ts { } function checkDeclarationInitializer(declaration: VariableLikeDeclaration) { - const type = checkExpressionCached(declaration.initializer); + const type = getTypeOfExpression(declaration.initializer, /*cache*/ true); return getCombinedNodeFlags(declaration) & NodeFlags.Const || getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); @@ -16204,10 +16204,12 @@ namespace ts { // Returns the type of an expression. Unlike checkExpression, this function is simply concerned // with computing the type and may not fully check all contained sub-expressions for errors. - function getTypeOfExpression(node: Expression) { + // A cache argument of true indicates that if the function performs a full type check, it is ok + // to cache the result. + function getTypeOfExpression(node: Expression, cache?: boolean) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === SyntaxKind.CallExpression && (node).expression.kind !== SyntaxKind.SuperKeyword) { + if (node.kind === SyntaxKind.CallExpression && (node).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(node, /*checkArgumentIsStringLiteral*/true)) { const funcType = checkNonNullExpression((node).expression); const signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -16217,7 +16219,7 @@ namespace ts { // Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions // should have a parameter that indicates whether full error checking is required such that // we can perform the optimizations locally. - return checkExpression(node); + return cache ? checkExpressionCached(node) : checkExpression(node); } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When From 6995055c861c2983acc9901da8c9b07779e27b92 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 3 Mar 2017 14:32:59 -0800 Subject: [PATCH 090/167] Accept new baselines --- .../reference/ambientRequireFunction.types | 2 +- .../controlFlowIterationErrors.errors.txt | 18 +----------------- ...implicitAnyFromCircularInference.errors.txt | 5 +---- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/tests/baselines/reference/ambientRequireFunction.types b/tests/baselines/reference/ambientRequireFunction.types index e0341d97ec3..7b01a59268f 100644 --- a/tests/baselines/reference/ambientRequireFunction.types +++ b/tests/baselines/reference/ambientRequireFunction.types @@ -3,7 +3,7 @@ const fs = require("fs"); >fs : typeof "fs" ->require("fs") : any +>require("fs") : typeof "fs" >require : (moduleName: string) => any >"fs" : "fs" diff --git a/tests/baselines/reference/controlFlowIterationErrors.errors.txt b/tests/baselines/reference/controlFlowIterationErrors.errors.txt index 1f090ccd35f..bc4b19b0602 100644 --- a/tests/baselines/reference/controlFlowIterationErrors.errors.txt +++ b/tests/baselines/reference/controlFlowIterationErrors.errors.txt @@ -6,15 +6,9 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(35,17): error Type 'string' is not assignable to type 'number'. tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(46,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(77,13): error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(77,26): error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'. - Type 'true' is not assignable to type 'string | number'. -tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,13): error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'. - Type 'true' is not assignable to type 'string | number'. -==== tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts (8 errors) ==== +==== tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts (4 errors) ==== let cond: boolean; @@ -104,11 +98,6 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error x = "0"; while (cond) { let y = asNumber(x); - ~ -!!! error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - ~ -!!! error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'. -!!! error TS2345: Type 'true' is not assignable to type 'string | number'. x = y + 1; x; } @@ -120,11 +109,6 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error while (cond) { x; let y = asNumber(x); - ~ -!!! error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - ~ -!!! error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'. -!!! error TS2345: Type 'true' is not assignable to type 'string | number'. x = y + 1; x; } diff --git a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt index bb43d96b003..7d4dfa2cf5e 100644 --- a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt +++ b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt @@ -7,11 +7,10 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(18,10): error TS7024: F tests/cases/compiler/implicitAnyFromCircularInference.ts(23,10): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(26,10): error TS7023: 'h' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(28,14): error TS7023: 'foo' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -tests/cases/compiler/implicitAnyFromCircularInference.ts(41,5): error TS7022: 's' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. tests/cases/compiler/implicitAnyFromCircularInference.ts(46,9): error TS7023: 'x' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -==== tests/cases/compiler/implicitAnyFromCircularInference.ts (11 errors) ==== +==== tests/cases/compiler/implicitAnyFromCircularInference.ts (10 errors) ==== // Error expected var a: typeof a; @@ -71,8 +70,6 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(46,9): error TS7023: 'x class C { // Error expected s = foo(this); - ~~~~~~~~~~~~~~ -!!! error TS7022: 's' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. } class D { From c2431ade0cf271d2cbec7b651f06030493ec23a8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 3 Mar 2017 14:33:07 -0800 Subject: [PATCH 091/167] Add regression test --- .../circularInferredTypeOfVariable.js | 44 +++++++++++++++++ .../circularInferredTypeOfVariable.symbols | 34 ++++++++++++++ .../circularInferredTypeOfVariable.types | 47 +++++++++++++++++++ .../circularInferredTypeOfVariable.ts | 20 ++++++++ 4 files changed, 145 insertions(+) create mode 100644 tests/baselines/reference/circularInferredTypeOfVariable.js create mode 100644 tests/baselines/reference/circularInferredTypeOfVariable.symbols create mode 100644 tests/baselines/reference/circularInferredTypeOfVariable.types create mode 100644 tests/cases/compiler/circularInferredTypeOfVariable.ts diff --git a/tests/baselines/reference/circularInferredTypeOfVariable.js b/tests/baselines/reference/circularInferredTypeOfVariable.js new file mode 100644 index 00000000000..38c5334761a --- /dev/null +++ b/tests/baselines/reference/circularInferredTypeOfVariable.js @@ -0,0 +1,44 @@ +//// [circularInferredTypeOfVariable.ts] + +// Repro from #14428 + +(async () => { + function foo(p: string[]): string[] { + return []; + } + + function bar(p: string[]): string[] { + return []; + } + + let a1: string[] | undefined = []; + + while (true) { + let a2 = foo(a1!); + a1 = await bar(a2); + } +}); + +//// [circularInferredTypeOfVariable.js] +// Repro from #14428 +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +(() => __awaiter(this, void 0, void 0, function* () { + function foo(p) { + return []; + } + function bar(p) { + return []; + } + let a1 = []; + while (true) { + let a2 = foo(a1); + a1 = yield bar(a2); + } +})); diff --git a/tests/baselines/reference/circularInferredTypeOfVariable.symbols b/tests/baselines/reference/circularInferredTypeOfVariable.symbols new file mode 100644 index 00000000000..653978f0e83 --- /dev/null +++ b/tests/baselines/reference/circularInferredTypeOfVariable.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/circularInferredTypeOfVariable.ts === + +// Repro from #14428 + +(async () => { + function foo(p: string[]): string[] { +>foo : Symbol(foo, Decl(circularInferredTypeOfVariable.ts, 3, 14)) +>p : Symbol(p, Decl(circularInferredTypeOfVariable.ts, 4, 17)) + + return []; + } + + function bar(p: string[]): string[] { +>bar : Symbol(bar, Decl(circularInferredTypeOfVariable.ts, 6, 5)) +>p : Symbol(p, Decl(circularInferredTypeOfVariable.ts, 8, 17)) + + return []; + } + + let a1: string[] | undefined = []; +>a1 : Symbol(a1, Decl(circularInferredTypeOfVariable.ts, 12, 7)) + + while (true) { + let a2 = foo(a1!); +>a2 : Symbol(a2, Decl(circularInferredTypeOfVariable.ts, 15, 11)) +>foo : Symbol(foo, Decl(circularInferredTypeOfVariable.ts, 3, 14)) +>a1 : Symbol(a1, Decl(circularInferredTypeOfVariable.ts, 12, 7)) + + a1 = await bar(a2); +>a1 : Symbol(a1, Decl(circularInferredTypeOfVariable.ts, 12, 7)) +>bar : Symbol(bar, Decl(circularInferredTypeOfVariable.ts, 6, 5)) +>a2 : Symbol(a2, Decl(circularInferredTypeOfVariable.ts, 15, 11)) + } +}); diff --git a/tests/baselines/reference/circularInferredTypeOfVariable.types b/tests/baselines/reference/circularInferredTypeOfVariable.types new file mode 100644 index 00000000000..df227bd9ae0 --- /dev/null +++ b/tests/baselines/reference/circularInferredTypeOfVariable.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/circularInferredTypeOfVariable.ts === + +// Repro from #14428 + +(async () => { +>(async () => { function foo(p: string[]): string[] { return []; } function bar(p: string[]): string[] { return []; } let a1: string[] | undefined = []; while (true) { let a2 = foo(a1!); a1 = await bar(a2); }}) : () => Promise +>async () => { function foo(p: string[]): string[] { return []; } function bar(p: string[]): string[] { return []; } let a1: string[] | undefined = []; while (true) { let a2 = foo(a1!); a1 = await bar(a2); }} : () => Promise + + function foo(p: string[]): string[] { +>foo : (p: string[]) => string[] +>p : string[] + + return []; +>[] : undefined[] + } + + function bar(p: string[]): string[] { +>bar : (p: string[]) => string[] +>p : string[] + + return []; +>[] : undefined[] + } + + let a1: string[] | undefined = []; +>a1 : string[] +>[] : undefined[] + + while (true) { +>true : true + + let a2 = foo(a1!); +>a2 : string[] +>foo(a1!) : string[] +>foo : (p: string[]) => string[] +>a1! : string[] +>a1 : string[] + + a1 = await bar(a2); +>a1 = await bar(a2) : string[] +>a1 : string[] +>await bar(a2) : string[] +>bar(a2) : string[] +>bar : (p: string[]) => string[] +>a2 : string[] + } +}); diff --git a/tests/cases/compiler/circularInferredTypeOfVariable.ts b/tests/cases/compiler/circularInferredTypeOfVariable.ts new file mode 100644 index 00000000000..662b6bfc8d8 --- /dev/null +++ b/tests/cases/compiler/circularInferredTypeOfVariable.ts @@ -0,0 +1,20 @@ +// @target: es6 + +// Repro from #14428 + +(async () => { + function foo(p: string[]): string[] { + return []; + } + + function bar(p: string[]): string[] { + return []; + } + + let a1: string[] | undefined = []; + + while (true) { + let a2 = foo(a1!); + a1 = await bar(a2); + } +}); \ No newline at end of file From 56e2735f5677811d5b519e18b0a48d352c79f647 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 3 Mar 2017 14:57:14 -0800 Subject: [PATCH 092/167] Fix fourslash test --- tests/cases/fourslash/extendArrayInterfaceMember.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/fourslash/extendArrayInterfaceMember.ts b/tests/cases/fourslash/extendArrayInterfaceMember.ts index ef3c06b2053..22aeed01f1d 100644 --- a/tests/cases/fourslash/extendArrayInterfaceMember.ts +++ b/tests/cases/fourslash/extendArrayInterfaceMember.ts @@ -10,7 +10,7 @@ verify.numberOfErrorsInCurrentFile(1); // - Supplied parameters do not match any signature of call target. // - Could not select overload for 'call' expression. -verify.quickInfoAt("y", "var y: any"); +verify.quickInfoAt("y", "var y: number"); goTo.eof(); edit.insert("interface Array { pop(def: T): T; }"); From efea81b8a038089c28a03dd03225e1a2b309a9f1 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 5 Mar 2017 14:07:33 -0800 Subject: [PATCH 093/167] Add failing repro --- .../controlFlow/typeGuardsTypeParameters.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts diff --git a/tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts b/tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts new file mode 100644 index 00000000000..169dbc7a7c8 --- /dev/null +++ b/tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts @@ -0,0 +1,35 @@ +// @strictNullChecks: true + +// Type guards involving type parameters produce intersection types + +class C { + prop: string; +} + +function f1(x: T) { + if (x instanceof C) { + let v1: T = x; + let v2: C = x; + x.prop; + } +} + +function f2(x: T) { + if (typeof x === "string") { + let v1: T = x; + let v2: string = x; + x.length; + } +} + +// Repro from #13872 + +function fun(item: { [P in keyof T]: T[P] }) { + const strings: string[] = []; + for (const key in item) { + const value = item[key]; + if (typeof value === "string") { + strings.push(value); + } + } +} From 4c71a7c084744cb7d29011c3757822242c64db18 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 5 Mar 2017 14:12:13 -0800 Subject: [PATCH 094/167] Accept error baselines --- .../typeGuardsTypeParameters.errors.txt | 47 +++++++++++++ .../reference/typeGuardsTypeParameters.js | 68 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 tests/baselines/reference/typeGuardsTypeParameters.errors.txt create mode 100644 tests/baselines/reference/typeGuardsTypeParameters.js diff --git a/tests/baselines/reference/typeGuardsTypeParameters.errors.txt b/tests/baselines/reference/typeGuardsTypeParameters.errors.txt new file mode 100644 index 00000000000..46eb198f425 --- /dev/null +++ b/tests/baselines/reference/typeGuardsTypeParameters.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts(10,13): error TS2322: Type 'C' is not assignable to type 'T'. +tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts(20,11): error TS2339: Property 'length' does not exist on type 'never'. +tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts(31,26): error TS2345: Argument of type 'T[keyof T]' is not assignable to parameter of type 'string'. + + +==== tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts (3 errors) ==== + + // Type guards involving type parameters produce intersection types + + class C { + prop: string; + } + + function f1(x: T) { + if (x instanceof C) { + let v1: T = x; + ~~ +!!! error TS2322: Type 'C' is not assignable to type 'T'. + let v2: C = x; + x.prop; + } + } + + function f2(x: T) { + if (typeof x === "string") { + let v1: T = x; + let v2: string = x; + x.length; + ~~~~~~ +!!! error TS2339: Property 'length' does not exist on type 'never'. + } + } + + // Repro from #13872 + + function fun(item: { [P in keyof T]: T[P] }) { + const strings: string[] = []; + for (const key in item) { + const value = item[key]; + if (typeof value === "string") { + strings.push(value); + ~~~~~ +!!! error TS2345: Argument of type 'T[keyof T]' is not assignable to parameter of type 'string'. + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsTypeParameters.js b/tests/baselines/reference/typeGuardsTypeParameters.js new file mode 100644 index 00000000000..bf0b1d2bac2 --- /dev/null +++ b/tests/baselines/reference/typeGuardsTypeParameters.js @@ -0,0 +1,68 @@ +//// [typeGuardsTypeParameters.ts] + +// Type guards involving type parameters produce intersection types + +class C { + prop: string; +} + +function f1(x: T) { + if (x instanceof C) { + let v1: T = x; + let v2: C = x; + x.prop; + } +} + +function f2(x: T) { + if (typeof x === "string") { + let v1: T = x; + let v2: string = x; + x.length; + } +} + +// Repro from #13872 + +function fun(item: { [P in keyof T]: T[P] }) { + const strings: string[] = []; + for (const key in item) { + const value = item[key]; + if (typeof value === "string") { + strings.push(value); + } + } +} + + +//// [typeGuardsTypeParameters.js] +// Type guards involving type parameters produce intersection types +var C = (function () { + function C() { + } + return C; +}()); +function f1(x) { + if (x instanceof C) { + var v1 = x; + var v2 = x; + x.prop; + } +} +function f2(x) { + if (typeof x === "string") { + var v1 = x; + var v2 = x; + x.length; + } +} +// Repro from #13872 +function fun(item) { + var strings = []; + for (var key in item) { + var value = item[key]; + if (typeof value === "string") { + strings.push(value); + } + } +} From 91b658da36e1b9a4eb6f19aec6d88f69cbc193c6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 5 Mar 2017 14:12:55 -0800 Subject: [PATCH 095/167] Construct intersection types for type guards involving type parameters --- src/compiler/checker.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a4c0acc405d..5685e54542f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9843,9 +9843,8 @@ namespace ts { if (flags & TypeFlags.NonPrimitive) { return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; } - if (flags & TypeFlags.TypeParameter) { - const constraint = getConstraintOfTypeParameter(type); - return getTypeFacts(constraint || emptyObjectType); + if (flags & TypeFlags.TypeVariable) { + return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } if (flags & TypeFlags.UnionOrIntersection) { return getTypeFactsOfTypes((type).types); @@ -10632,8 +10631,16 @@ namespace ts { // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. const targetType = typeofTypesByName.get(literal.text); - if (targetType && isTypeSubtypeOf(targetType, type)) { - return targetType; + if (targetType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + if (type.flags & TypeFlags.TypeVariable) { + const constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(targetType, constraint)) { + return getIntersectionType([type, targetType]); + } + } } } const facts = assumeTrue ? @@ -10731,10 +10738,9 @@ namespace ts { // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the // two types. - const targetType = type.flags & TypeFlags.TypeParameter ? getApparentType(type) : type; return isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, targetType) ? candidate : + isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } From af686adf1f64fb31bd6f212777e6ee4f8ff2402e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 5 Mar 2017 14:19:20 -0800 Subject: [PATCH 096/167] Accept new baselines --- .../typeGuardsTypeParameters.errors.txt | 47 -------- .../typeGuardsTypeParameters.symbols | 98 ++++++++++++++++ .../reference/typeGuardsTypeParameters.types | 108 ++++++++++++++++++ 3 files changed, 206 insertions(+), 47 deletions(-) delete mode 100644 tests/baselines/reference/typeGuardsTypeParameters.errors.txt create mode 100644 tests/baselines/reference/typeGuardsTypeParameters.symbols create mode 100644 tests/baselines/reference/typeGuardsTypeParameters.types diff --git a/tests/baselines/reference/typeGuardsTypeParameters.errors.txt b/tests/baselines/reference/typeGuardsTypeParameters.errors.txt deleted file mode 100644 index 46eb198f425..00000000000 --- a/tests/baselines/reference/typeGuardsTypeParameters.errors.txt +++ /dev/null @@ -1,47 +0,0 @@ -tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts(10,13): error TS2322: Type 'C' is not assignable to type 'T'. -tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts(20,11): error TS2339: Property 'length' does not exist on type 'never'. -tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts(31,26): error TS2345: Argument of type 'T[keyof T]' is not assignable to parameter of type 'string'. - - -==== tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts (3 errors) ==== - - // Type guards involving type parameters produce intersection types - - class C { - prop: string; - } - - function f1(x: T) { - if (x instanceof C) { - let v1: T = x; - ~~ -!!! error TS2322: Type 'C' is not assignable to type 'T'. - let v2: C = x; - x.prop; - } - } - - function f2(x: T) { - if (typeof x === "string") { - let v1: T = x; - let v2: string = x; - x.length; - ~~~~~~ -!!! error TS2339: Property 'length' does not exist on type 'never'. - } - } - - // Repro from #13872 - - function fun(item: { [P in keyof T]: T[P] }) { - const strings: string[] = []; - for (const key in item) { - const value = item[key]; - if (typeof value === "string") { - strings.push(value); - ~~~~~ -!!! error TS2345: Argument of type 'T[keyof T]' is not assignable to parameter of type 'string'. - } - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsTypeParameters.symbols b/tests/baselines/reference/typeGuardsTypeParameters.symbols new file mode 100644 index 00000000000..53e6086c0fd --- /dev/null +++ b/tests/baselines/reference/typeGuardsTypeParameters.symbols @@ -0,0 +1,98 @@ +=== tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts === + +// Type guards involving type parameters produce intersection types + +class C { +>C : Symbol(C, Decl(typeGuardsTypeParameters.ts, 0, 0)) + + prop: string; +>prop : Symbol(C.prop, Decl(typeGuardsTypeParameters.ts, 3, 9)) +} + +function f1(x: T) { +>f1 : Symbol(f1, Decl(typeGuardsTypeParameters.ts, 5, 1)) +>T : Symbol(T, Decl(typeGuardsTypeParameters.ts, 7, 12)) +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 7, 15)) +>T : Symbol(T, Decl(typeGuardsTypeParameters.ts, 7, 12)) + + if (x instanceof C) { +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 7, 15)) +>C : Symbol(C, Decl(typeGuardsTypeParameters.ts, 0, 0)) + + let v1: T = x; +>v1 : Symbol(v1, Decl(typeGuardsTypeParameters.ts, 9, 11)) +>T : Symbol(T, Decl(typeGuardsTypeParameters.ts, 7, 12)) +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 7, 15)) + + let v2: C = x; +>v2 : Symbol(v2, Decl(typeGuardsTypeParameters.ts, 10, 11)) +>C : Symbol(C, Decl(typeGuardsTypeParameters.ts, 0, 0)) +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 7, 15)) + + x.prop; +>x.prop : Symbol(C.prop, Decl(typeGuardsTypeParameters.ts, 3, 9)) +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 7, 15)) +>prop : Symbol(C.prop, Decl(typeGuardsTypeParameters.ts, 3, 9)) + } +} + +function f2(x: T) { +>f2 : Symbol(f2, Decl(typeGuardsTypeParameters.ts, 13, 1)) +>T : Symbol(T, Decl(typeGuardsTypeParameters.ts, 15, 12)) +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 15, 15)) +>T : Symbol(T, Decl(typeGuardsTypeParameters.ts, 15, 12)) + + if (typeof x === "string") { +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 15, 15)) + + let v1: T = x; +>v1 : Symbol(v1, Decl(typeGuardsTypeParameters.ts, 17, 11)) +>T : Symbol(T, Decl(typeGuardsTypeParameters.ts, 15, 12)) +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 15, 15)) + + let v2: string = x; +>v2 : Symbol(v2, Decl(typeGuardsTypeParameters.ts, 18, 11)) +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 15, 15)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(typeGuardsTypeParameters.ts, 15, 15)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } +} + +// Repro from #13872 + +function fun(item: { [P in keyof T]: T[P] }) { +>fun : Symbol(fun, Decl(typeGuardsTypeParameters.ts, 21, 1)) +>T : Symbol(T, Decl(typeGuardsTypeParameters.ts, 25, 13)) +>item : Symbol(item, Decl(typeGuardsTypeParameters.ts, 25, 16)) +>P : Symbol(P, Decl(typeGuardsTypeParameters.ts, 25, 25)) +>T : Symbol(T, Decl(typeGuardsTypeParameters.ts, 25, 13)) +>T : Symbol(T, Decl(typeGuardsTypeParameters.ts, 25, 13)) +>P : Symbol(P, Decl(typeGuardsTypeParameters.ts, 25, 25)) + + const strings: string[] = []; +>strings : Symbol(strings, Decl(typeGuardsTypeParameters.ts, 26, 9)) + + for (const key in item) { +>key : Symbol(key, Decl(typeGuardsTypeParameters.ts, 27, 14)) +>item : Symbol(item, Decl(typeGuardsTypeParameters.ts, 25, 16)) + + const value = item[key]; +>value : Symbol(value, Decl(typeGuardsTypeParameters.ts, 28, 13)) +>item : Symbol(item, Decl(typeGuardsTypeParameters.ts, 25, 16)) +>key : Symbol(key, Decl(typeGuardsTypeParameters.ts, 27, 14)) + + if (typeof value === "string") { +>value : Symbol(value, Decl(typeGuardsTypeParameters.ts, 28, 13)) + + strings.push(value); +>strings.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>strings : Symbol(strings, Decl(typeGuardsTypeParameters.ts, 26, 9)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>value : Symbol(value, Decl(typeGuardsTypeParameters.ts, 28, 13)) + } + } +} + diff --git a/tests/baselines/reference/typeGuardsTypeParameters.types b/tests/baselines/reference/typeGuardsTypeParameters.types new file mode 100644 index 00000000000..6825402cdc7 --- /dev/null +++ b/tests/baselines/reference/typeGuardsTypeParameters.types @@ -0,0 +1,108 @@ +=== tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts === + +// Type guards involving type parameters produce intersection types + +class C { +>C : C + + prop: string; +>prop : string +} + +function f1(x: T) { +>f1 : (x: T) => void +>T : T +>x : T +>T : T + + if (x instanceof C) { +>x instanceof C : boolean +>x : T +>C : typeof C + + let v1: T = x; +>v1 : T +>T : T +>x : T & C + + let v2: C = x; +>v2 : C +>C : C +>x : T & C + + x.prop; +>x.prop : string +>x : T & C +>prop : string + } +} + +function f2(x: T) { +>f2 : (x: T) => void +>T : T +>x : T +>T : T + + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : T +>"string" : "string" + + let v1: T = x; +>v1 : T +>T : T +>x : T & string + + let v2: string = x; +>v2 : string +>x : T & string + + x.length; +>x.length : number +>x : T & string +>length : number + } +} + +// Repro from #13872 + +function fun(item: { [P in keyof T]: T[P] }) { +>fun : (item: { [P in keyof T]: T[P]; }) => void +>T : T +>item : { [P in keyof T]: T[P]; } +>P : P +>T : T +>T : T +>P : P + + const strings: string[] = []; +>strings : string[] +>[] : never[] + + for (const key in item) { +>key : keyof T +>item : { [P in keyof T]: T[P]; } + + const value = item[key]; +>value : T[keyof T] +>item[key] : T[keyof T] +>item : { [P in keyof T]: T[P]; } +>key : keyof T + + if (typeof value === "string") { +>typeof value === "string" : boolean +>typeof value : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>value : T[keyof T] +>"string" : "string" + + strings.push(value); +>strings.push(value) : number +>strings.push : (...items: string[]) => number +>strings : string[] +>push : (...items: string[]) => number +>value : T[keyof T] & string + } + } +} + From b1520345bec020280c3cd8a38fca5f0d43f4761e Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sun, 5 Mar 2017 15:41:47 -0800 Subject: [PATCH 097/167] use ES6 library when building tslint rules (#14474) --- Jakefile.js | 12 +++++++++--- scripts/parallel-lint.js | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index f8be7c2b671..4512aa23794 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -328,8 +328,14 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts if (opts.stripInternal) { options += " --stripInternal"; } - - options += " --target es5 --lib es5,scripthost --noUnusedLocals --noUnusedParameters"; + options += " --target es5"; + if (opts.lib) { + options += " --lib " + opts.lib + } + else { + options += " --lib es5,scripthost" + } + options += " --noUnusedLocals --noUnusedParameters"; var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); @@ -1110,7 +1116,7 @@ desc("Compiles tslint rules to js"); task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"])); tslintRulesFiles.forEach(function (ruleFile, i) { compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, - { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint") }); + { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" }); }); desc("Emit the start of the build-rules fold"); diff --git a/scripts/parallel-lint.js b/scripts/parallel-lint.js index aec9960ce47..2ac84667d6f 100644 --- a/scripts/parallel-lint.js +++ b/scripts/parallel-lint.js @@ -1,5 +1,6 @@ var tslint = require("tslint"); var fs = require("fs"); +var path = require("path"); function getLinterOptions() { return { @@ -9,7 +10,7 @@ function getLinterOptions() { }; } function getLinterConfiguration() { - return require("../tslint.json"); + return tslint.Configuration.loadConfigurationFromPath(path.join(__dirname, "../tslint.json")); } function lintFileContents(options, configuration, path, contents) { From 7ed13d0c1ef96b2408cdaf39d57ba5c889fc9708 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 5 Mar 2017 16:51:58 -0800 Subject: [PATCH 098/167] Accept new tsconfig baselines --- .../tsConfig/Default initialized TSConfig/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../Initialized TSConfig with files options/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index ea891967cb5..74db1904dda 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "strict": false, "sourceMap": false } } \ No newline at end of file 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 abe135b4f16..8277fa5f4a2 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "strict": false, "sourceMap": false, "noUnusedLocals": true } 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 e28b66c8c2b..2402c4145a0 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "strict": false, "sourceMap": false, "jsx": "react" } 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 5273b3cb7c8..d73d25d9b9b 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "strict": false, "sourceMap": false }, "files": [ 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 fa9cb6cad84..7f7bde79e92 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "strict": false, "sourceMap": false, "lib": [ "es5", 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 ea891967cb5..74db1904dda 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "strict": false, "sourceMap": false } } \ No newline at end of file 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 3ff8208d9d6..587f661f1f0 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "strict": false, "sourceMap": false, "lib": [ "es5", 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 b1740ac4c12..4d6974281ce 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "strict": false, "sourceMap": false, "types": [ "jquery", From cc77225f35d8a04ea0288ec37c1c825eb4be6903 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 6 Mar 2017 06:21:56 -0800 Subject: [PATCH 099/167] Go back to using tslint@next --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b52eb6675e..3ffab4bfb13 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "through2": "latest", "travis-fold": "latest", "ts-node": "latest", - "tslint": "latest", + "tslint": "next", "typescript": "next" }, "scripts": { From d3b7058c2999f68c04278e15cbc29c91bcc44dc5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 6 Mar 2017 13:04:59 -0800 Subject: [PATCH 100/167] Change 'tsc --init' to default to 'strict: true' --- src/compiler/commandLineParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 17bbbcb8a56..dc692972891 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -525,7 +525,7 @@ namespace ts { export const defaultInitCompilerOptions: CompilerOptions = { module: ModuleKind.CommonJS, target: ScriptTarget.ES5, - strict: false, + strict: true, sourceMap: false, }; From de120b32e912e57886df689e291798dfa66c04db Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 6 Mar 2017 13:05:14 -0800 Subject: [PATCH 101/167] Accept new baselines --- .../tsConfig/Default initialized TSConfig/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../Initialized TSConfig with files options/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 74db1904dda..a4c1c449095 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "strict": false, + "strict": true, "sourceMap": false } } \ No newline at end of file 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 8277fa5f4a2..23061360bc2 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "strict": false, + "strict": true, "sourceMap": false, "noUnusedLocals": true } 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 2402c4145a0..16535c7960a 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "strict": false, + "strict": true, "sourceMap": false, "jsx": "react" } 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 d73d25d9b9b..133de87dc1d 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "strict": false, + "strict": true, "sourceMap": false }, "files": [ 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 7f7bde79e92..2ab8d9412ea 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "strict": false, + "strict": true, "sourceMap": false, "lib": [ "es5", 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 74db1904dda..a4c1c449095 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "strict": false, + "strict": true, "sourceMap": false } } \ No newline at end of file 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 587f661f1f0..5716902e02c 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "strict": false, + "strict": true, "sourceMap": false, "lib": [ "es5", 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 4d6974281ce..4fc209f9b9c 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 @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es5", - "strict": false, + "strict": true, "sourceMap": false, "types": [ "jquery", From ed071a9b02eedab11909c8a7e4736a53f0011361 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 6 Mar 2017 13:33:51 -0800 Subject: [PATCH 102/167] Only emit ESModule marker when there is no export equal and the file is external module --- src/compiler/transformers/module/module.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 52c6db707c1..c1f18e2021b 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -55,9 +55,7 @@ namespace ts { * @param node The SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node) - || !(isExternalModule(node) - || compilerOptions.isolatedModules)) { + if (isDeclarationFile(node) || !(isExternalModule(node) || compilerOptions.isolatedModules)) { return node; } @@ -74,6 +72,14 @@ namespace ts { return aggregateTransformFlags(updated); } + + function shouldEmitUnderscoreUnderscoreESModule() { + if (!currentModuleInfo.exportEquals && isExternalModule(currentSourceFile)) { + return true; + } + return false; + } + /** * Transforms a SourceFile into a CommonJS module. * @@ -85,7 +91,7 @@ namespace ts { const statements: Statement[] = []; const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + if (shouldEmitUnderscoreUnderscoreESModule()) { append(statements, createUnderscoreUnderscoreESModule()); } @@ -378,7 +384,7 @@ namespace ts { const statements: Statement[] = []; const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + if (shouldEmitUnderscoreUnderscoreESModule()) { append(statements, createUnderscoreUnderscoreESModule()); } From 8f7fd0918b6ce92d14506f84b558c36cb2f91ed8 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 6 Mar 2017 13:35:03 -0800 Subject: [PATCH 103/167] Set inference result to `any` isntead of `{}` for .js files if generic type parameter inference found no candidates --- src/compiler/checker.ts | 10 +- src/compiler/types.ts | 1 + .../reference/inferingFromAny.symbols | 282 ++++++++++++++++ .../baselines/reference/inferingFromAny.types | 301 ++++++++++++++++++ .../conformance/salsa/inferingFromAny.ts | 47 +++ 5 files changed, 638 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/inferingFromAny.symbols create mode 100644 tests/baselines/reference/inferingFromAny.types create mode 100644 tests/cases/conformance/salsa/inferingFromAny.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5d45af57343..c161dd3f065 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9177,13 +9177,14 @@ namespace ts { } } - function createInferenceContext(signature: Signature, inferUnionTypes: boolean): InferenceContext { + function createInferenceContext(signature: Signature, inferUnionTypes: boolean, useAnyForNoInferences: boolean): InferenceContext { const inferences = map(signature.typeParameters, createTypeInferencesObject); return { signature, inferUnionTypes, inferences, inferredTypes: new Array(signature.typeParameters.length), + useAnyForNoInferences }; } @@ -9613,6 +9614,9 @@ namespace ts { context.inferredTypes[index] = inferredType = instantiatedConstraint; } } + if (context.useAnyForNoInferences && !inferences.length && inferredType === emptyObjectType) { + context.inferredTypes[index] = inferredType = anyType; + } } else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { // If inference failed, it is necessary to record the index of the failed type parameter (the one we are on). @@ -13634,7 +13638,7 @@ namespace ts { // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature: Signature, contextualSignature: Signature, contextualMapper: TypeMapper): Signature { - const context = createInferenceContext(signature, /*inferUnionTypes*/ true); + const context = createInferenceContext(signature, /*inferUnionTypes*/ true, /*useAnyForNoInferences*/ false); forEachMatchingParameterType(contextualSignature, signature, (source, target) => { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypesWithContext(context, instantiateType(source, contextualMapper), target); @@ -14335,7 +14339,7 @@ namespace ts { let candidate: Signature; let typeArgumentsAreValid: boolean; const inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false) + ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false, /*useAnyForNoInferences*/ isInJavaScriptFile(node)) : undefined; while (true) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f96f8623885..de22ae06be3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3235,6 +3235,7 @@ mapper?: TypeMapper; // Type mapper for this inference context failedTypeParameterIndex?: number; // Index of type parameter for which inference failed // It is optional because in contextual signature instantiation, nothing fails + useAnyForNoInferences?: boolean; // Use any instead of {} for no inferences } /* @internal */ diff --git a/tests/baselines/reference/inferingFromAny.symbols b/tests/baselines/reference/inferingFromAny.symbols new file mode 100644 index 00000000000..cabb8fb07b7 --- /dev/null +++ b/tests/baselines/reference/inferingFromAny.symbols @@ -0,0 +1,282 @@ +=== tests/cases/conformance/salsa/a.ts === + +var a: any; +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t: [any, any]; +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) + +declare function f1(t: T): T +>f1 : Symbol(f1, Decl(a.ts, 2, 18)) +>T : Symbol(T, Decl(a.ts, 3, 20)) +>t : Symbol(t, Decl(a.ts, 3, 23)) +>T : Symbol(T, Decl(a.ts, 3, 20)) +>T : Symbol(T, Decl(a.ts, 3, 20)) + +declare function f2(t: T[]): T; +>f2 : Symbol(f2, Decl(a.ts, 3, 31)) +>T : Symbol(T, Decl(a.ts, 4, 20)) +>t : Symbol(t, Decl(a.ts, 4, 23)) +>T : Symbol(T, Decl(a.ts, 4, 20)) +>T : Symbol(T, Decl(a.ts, 4, 20)) + +declare function f3(t: [T, U]): [T, U]; +>f3 : Symbol(f3, Decl(a.ts, 4, 34)) +>T : Symbol(T, Decl(a.ts, 5, 20)) +>U : Symbol(U, Decl(a.ts, 5, 22)) +>t : Symbol(t, Decl(a.ts, 5, 26)) +>T : Symbol(T, Decl(a.ts, 5, 20)) +>U : Symbol(U, Decl(a.ts, 5, 22)) +>T : Symbol(T, Decl(a.ts, 5, 20)) +>U : Symbol(U, Decl(a.ts, 5, 22)) + +declare function f4(x: { bar: T; baz: T }): T; +>f4 : Symbol(f4, Decl(a.ts, 5, 45)) +>T : Symbol(T, Decl(a.ts, 6, 20)) +>x : Symbol(x, Decl(a.ts, 6, 23)) +>bar : Symbol(bar, Decl(a.ts, 6, 27)) +>T : Symbol(T, Decl(a.ts, 6, 20)) +>baz : Symbol(baz, Decl(a.ts, 6, 35)) +>T : Symbol(T, Decl(a.ts, 6, 20)) +>T : Symbol(T, Decl(a.ts, 6, 20)) + +declare function f5(x: (a: T) => void): T; +>f5 : Symbol(f5, Decl(a.ts, 6, 49)) +>T : Symbol(T, Decl(a.ts, 7, 20)) +>x : Symbol(x, Decl(a.ts, 7, 23)) +>a : Symbol(a, Decl(a.ts, 7, 27)) +>T : Symbol(T, Decl(a.ts, 7, 20)) +>T : Symbol(T, Decl(a.ts, 7, 20)) + +declare function f6(x: new (a: T) => {}): T; +>f6 : Symbol(f6, Decl(a.ts, 7, 45)) +>T : Symbol(T, Decl(a.ts, 8, 20)) +>x : Symbol(x, Decl(a.ts, 8, 23)) +>a : Symbol(a, Decl(a.ts, 8, 31)) +>T : Symbol(T, Decl(a.ts, 8, 20)) +>T : Symbol(T, Decl(a.ts, 8, 20)) + +declare function f7(x: (a: any) => a is T): T; +>f7 : Symbol(f7, Decl(a.ts, 8, 47)) +>T : Symbol(T, Decl(a.ts, 9, 20)) +>x : Symbol(x, Decl(a.ts, 9, 23)) +>a : Symbol(a, Decl(a.ts, 9, 27)) +>a : Symbol(a, Decl(a.ts, 9, 27)) +>T : Symbol(T, Decl(a.ts, 9, 20)) +>T : Symbol(T, Decl(a.ts, 9, 20)) + +declare function f8(x: () => T): T; +>f8 : Symbol(f8, Decl(a.ts, 9, 49)) +>T : Symbol(T, Decl(a.ts, 10, 20)) +>x : Symbol(x, Decl(a.ts, 10, 23)) +>T : Symbol(T, Decl(a.ts, 10, 20)) +>T : Symbol(T, Decl(a.ts, 10, 20)) + +declare function f9(x: new () => T): T; +>f9 : Symbol(f9, Decl(a.ts, 10, 38)) +>T : Symbol(T, Decl(a.ts, 11, 20)) +>x : Symbol(x, Decl(a.ts, 11, 23)) +>T : Symbol(T, Decl(a.ts, 11, 20)) +>T : Symbol(T, Decl(a.ts, 11, 20)) + +declare function f10(x: { [x: string]: T }): T; +>f10 : Symbol(f10, Decl(a.ts, 11, 42)) +>T : Symbol(T, Decl(a.ts, 12, 21)) +>x : Symbol(x, Decl(a.ts, 12, 24)) +>x : Symbol(x, Decl(a.ts, 12, 30)) +>T : Symbol(T, Decl(a.ts, 12, 21)) +>T : Symbol(T, Decl(a.ts, 12, 21)) + +declare function f11(x: { [x: number]: T }): T; +>f11 : Symbol(f11, Decl(a.ts, 12, 50)) +>T : Symbol(T, Decl(a.ts, 13, 21)) +>x : Symbol(x, Decl(a.ts, 13, 24)) +>x : Symbol(x, Decl(a.ts, 13, 30)) +>T : Symbol(T, Decl(a.ts, 13, 21)) +>T : Symbol(T, Decl(a.ts, 13, 21)) + +declare function f12(x: T | U): [T, U]; +>f12 : Symbol(f12, Decl(a.ts, 13, 50)) +>T : Symbol(T, Decl(a.ts, 14, 21)) +>U : Symbol(U, Decl(a.ts, 14, 23)) +>x : Symbol(x, Decl(a.ts, 14, 27)) +>T : Symbol(T, Decl(a.ts, 14, 21)) +>U : Symbol(U, Decl(a.ts, 14, 23)) +>T : Symbol(T, Decl(a.ts, 14, 21)) +>U : Symbol(U, Decl(a.ts, 14, 23)) + +declare function f13(x: T & U): [T, U]; +>f13 : Symbol(f13, Decl(a.ts, 14, 45)) +>T : Symbol(T, Decl(a.ts, 15, 21)) +>U : Symbol(U, Decl(a.ts, 15, 23)) +>x : Symbol(x, Decl(a.ts, 15, 27)) +>T : Symbol(T, Decl(a.ts, 15, 21)) +>U : Symbol(U, Decl(a.ts, 15, 23)) +>T : Symbol(T, Decl(a.ts, 15, 21)) +>U : Symbol(U, Decl(a.ts, 15, 23)) + +declare function f14(x: { a: T | U, b: U & T }): [T, U]; +>f14 : Symbol(f14, Decl(a.ts, 15, 45)) +>T : Symbol(T, Decl(a.ts, 16, 21)) +>U : Symbol(U, Decl(a.ts, 16, 23)) +>x : Symbol(x, Decl(a.ts, 16, 27)) +>a : Symbol(a, Decl(a.ts, 16, 31)) +>T : Symbol(T, Decl(a.ts, 16, 21)) +>U : Symbol(U, Decl(a.ts, 16, 23)) +>b : Symbol(b, Decl(a.ts, 16, 41)) +>U : Symbol(U, Decl(a.ts, 16, 23)) +>T : Symbol(T, Decl(a.ts, 16, 21)) +>T : Symbol(T, Decl(a.ts, 16, 21)) +>U : Symbol(U, Decl(a.ts, 16, 23)) + +interface I { } +>I : Symbol(I, Decl(a.ts, 16, 62)) +>T : Symbol(T, Decl(a.ts, 17, 12)) + +declare function f15(x: I): T; +>f15 : Symbol(f15, Decl(a.ts, 17, 18)) +>T : Symbol(T, Decl(a.ts, 18, 21)) +>x : Symbol(x, Decl(a.ts, 18, 24)) +>I : Symbol(I, Decl(a.ts, 16, 62)) +>T : Symbol(T, Decl(a.ts, 18, 21)) +>T : Symbol(T, Decl(a.ts, 18, 21)) + +declare function f16(x: Partial): T; +>f16 : Symbol(f16, Decl(a.ts, 18, 36)) +>T : Symbol(T, Decl(a.ts, 19, 21)) +>x : Symbol(x, Decl(a.ts, 19, 24)) +>Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(a.ts, 19, 21)) +>T : Symbol(T, Decl(a.ts, 19, 21)) + +declare function f17(x: {[P in keyof T]: K}): T; +>f17 : Symbol(f17, Decl(a.ts, 19, 42)) +>T : Symbol(T, Decl(a.ts, 20, 21)) +>K : Symbol(K, Decl(a.ts, 20, 23)) +>x : Symbol(x, Decl(a.ts, 20, 27)) +>P : Symbol(P, Decl(a.ts, 20, 32)) +>T : Symbol(T, Decl(a.ts, 20, 21)) +>K : Symbol(K, Decl(a.ts, 20, 23)) +>T : Symbol(T, Decl(a.ts, 20, 21)) + +declare function f18(x: {[P in K]: T[P]}): T; +>f18 : Symbol(f18, Decl(a.ts, 20, 54)) +>T : Symbol(T, Decl(a.ts, 21, 21)) +>K : Symbol(K, Decl(a.ts, 21, 23)) +>T : Symbol(T, Decl(a.ts, 21, 21)) +>x : Symbol(x, Decl(a.ts, 21, 43)) +>P : Symbol(P, Decl(a.ts, 21, 48)) +>K : Symbol(K, Decl(a.ts, 21, 23)) +>T : Symbol(T, Decl(a.ts, 21, 21)) +>P : Symbol(P, Decl(a.ts, 21, 48)) +>T : Symbol(T, Decl(a.ts, 21, 21)) + +declare function f19(k: K, x: T[K]): T; +>f19 : Symbol(f19, Decl(a.ts, 21, 67)) +>T : Symbol(T, Decl(a.ts, 22, 21)) +>K : Symbol(K, Decl(a.ts, 22, 23)) +>T : Symbol(T, Decl(a.ts, 22, 21)) +>k : Symbol(k, Decl(a.ts, 22, 43)) +>K : Symbol(K, Decl(a.ts, 22, 23)) +>x : Symbol(x, Decl(a.ts, 22, 48)) +>T : Symbol(T, Decl(a.ts, 22, 21)) +>K : Symbol(K, Decl(a.ts, 22, 23)) +>T : Symbol(T, Decl(a.ts, 22, 21)) + +=== tests/cases/conformance/salsa/a.js === +var a = f1(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f1 : Symbol(f1, Decl(a.ts, 2, 18)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f2(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f2 : Symbol(f2, Decl(a.ts, 3, 31)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t = f3(a); +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) +>f3 : Symbol(f3, Decl(a.ts, 4, 34)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f4(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f4 : Symbol(f4, Decl(a.ts, 5, 45)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f5(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f5 : Symbol(f5, Decl(a.ts, 6, 49)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f6(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f6 : Symbol(f6, Decl(a.ts, 7, 45)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f7(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f7 : Symbol(f7, Decl(a.ts, 8, 47)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f8(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f8 : Symbol(f8, Decl(a.ts, 9, 49)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f9(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f9 : Symbol(f9, Decl(a.ts, 10, 38)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f10(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f10 : Symbol(f10, Decl(a.ts, 11, 42)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f11(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f11 : Symbol(f11, Decl(a.ts, 12, 50)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t = f12(a); +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) +>f12 : Symbol(f12, Decl(a.ts, 13, 50)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t = f13(a); +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) +>f13 : Symbol(f13, Decl(a.ts, 14, 45)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var t = f14(a); +>t : Symbol(t, Decl(a.ts, 2, 3), Decl(a.js, 2, 3), Decl(a.js, 11, 3), Decl(a.js, 12, 3), Decl(a.js, 13, 3)) +>f14 : Symbol(f14, Decl(a.ts, 15, 45)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f15(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f15 : Symbol(f15, Decl(a.ts, 17, 18)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f16(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f16 : Symbol(f16, Decl(a.ts, 18, 36)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f17(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f17 : Symbol(f17, Decl(a.ts, 19, 42)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f18(a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f18 : Symbol(f18, Decl(a.ts, 20, 54)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + +var a = f19(a, a); +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>f19 : Symbol(f19, Decl(a.ts, 21, 67)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) +>a : Symbol(a, Decl(a.ts, 1, 3), Decl(a.js, 0, 3), Decl(a.js, 1, 3), Decl(a.js, 3, 3), Decl(a.js, 4, 3), Decl(a.js, 5, 3), Decl(a.js, 6, 3), Decl(a.js, 7, 3), Decl(a.js, 8, 3), Decl(a.js, 9, 3), Decl(a.js, 10, 3), Decl(a.js, 14, 3), Decl(a.js, 15, 3), Decl(a.js, 16, 3), Decl(a.js, 17, 3), Decl(a.js, 18, 3)) + diff --git a/tests/baselines/reference/inferingFromAny.types b/tests/baselines/reference/inferingFromAny.types new file mode 100644 index 00000000000..c991f12f45c --- /dev/null +++ b/tests/baselines/reference/inferingFromAny.types @@ -0,0 +1,301 @@ +=== tests/cases/conformance/salsa/a.ts === + +var a: any; +>a : any + +var t: [any, any]; +>t : [any, any] + +declare function f1(t: T): T +>f1 : (t: T) => T +>T : T +>t : T +>T : T +>T : T + +declare function f2(t: T[]): T; +>f2 : (t: T[]) => T +>T : T +>t : T[] +>T : T +>T : T + +declare function f3(t: [T, U]): [T, U]; +>f3 : (t: [T, U]) => [T, U] +>T : T +>U : U +>t : [T, U] +>T : T +>U : U +>T : T +>U : U + +declare function f4(x: { bar: T; baz: T }): T; +>f4 : (x: { bar: T; baz: T; }) => T +>T : T +>x : { bar: T; baz: T; } +>bar : T +>T : T +>baz : T +>T : T +>T : T + +declare function f5(x: (a: T) => void): T; +>f5 : (x: (a: T) => void) => T +>T : T +>x : (a: T) => void +>a : T +>T : T +>T : T + +declare function f6(x: new (a: T) => {}): T; +>f6 : (x: new (a: T) => {}) => T +>T : T +>x : new (a: T) => {} +>a : T +>T : T +>T : T + +declare function f7(x: (a: any) => a is T): T; +>f7 : (x: (a: any) => a is T) => T +>T : T +>x : (a: any) => a is T +>a : any +>a : any +>T : T +>T : T + +declare function f8(x: () => T): T; +>f8 : (x: () => T) => T +>T : T +>x : () => T +>T : T +>T : T + +declare function f9(x: new () => T): T; +>f9 : (x: new () => T) => T +>T : T +>x : new () => T +>T : T +>T : T + +declare function f10(x: { [x: string]: T }): T; +>f10 : (x: { [x: string]: T; }) => T +>T : T +>x : { [x: string]: T; } +>x : string +>T : T +>T : T + +declare function f11(x: { [x: number]: T }): T; +>f11 : (x: { [x: number]: T; }) => T +>T : T +>x : { [x: number]: T; } +>x : number +>T : T +>T : T + +declare function f12(x: T | U): [T, U]; +>f12 : (x: T | U) => [T, U] +>T : T +>U : U +>x : T | U +>T : T +>U : U +>T : T +>U : U + +declare function f13(x: T & U): [T, U]; +>f13 : (x: T & U) => [T, U] +>T : T +>U : U +>x : T & U +>T : T +>U : U +>T : T +>U : U + +declare function f14(x: { a: T | U, b: U & T }): [T, U]; +>f14 : (x: { a: T | U; b: U & T; }) => [T, U] +>T : T +>U : U +>x : { a: T | U; b: U & T; } +>a : T | U +>T : T +>U : U +>b : U & T +>U : U +>T : T +>T : T +>U : U + +interface I { } +>I : I +>T : T + +declare function f15(x: I): T; +>f15 : (x: I) => T +>T : T +>x : I +>I : I +>T : T +>T : T + +declare function f16(x: Partial): T; +>f16 : (x: Partial) => T +>T : T +>x : Partial +>Partial : Partial +>T : T +>T : T + +declare function f17(x: {[P in keyof T]: K}): T; +>f17 : (x: { [P in keyof T]: K; }) => T +>T : T +>K : K +>x : { [P in keyof T]: K; } +>P : P +>T : T +>K : K +>T : T + +declare function f18(x: {[P in K]: T[P]}): T; +>f18 : (x: { [P in K]: T[P]; }) => T +>T : T +>K : K +>T : T +>x : { [P in K]: T[P]; } +>P : P +>K : K +>T : T +>P : P +>T : T + +declare function f19(k: K, x: T[K]): T; +>f19 : (k: K, x: T[K]) => T +>T : T +>K : K +>T : T +>k : K +>K : K +>x : T[K] +>T : T +>K : K +>T : T + +=== tests/cases/conformance/salsa/a.js === +var a = f1(a); +>a : any +>f1(a) : any +>f1 : (t: T) => T +>a : any + +var a = f2(a); +>a : any +>f2(a) : any +>f2 : (t: T[]) => T +>a : any + +var t = f3(a); +>t : [any, any] +>f3(a) : [any, any] +>f3 : (t: [T, U]) => [T, U] +>a : any + +var a = f4(a); +>a : any +>f4(a) : any +>f4 : (x: { bar: T; baz: T; }) => T +>a : any + +var a = f5(a); +>a : any +>f5(a) : any +>f5 : (x: (a: T) => void) => T +>a : any + +var a = f6(a); +>a : any +>f6(a) : any +>f6 : (x: new (a: T) => {}) => T +>a : any + +var a = f7(a); +>a : any +>f7(a) : any +>f7 : (x: (a: any) => a is T) => T +>a : any + +var a = f8(a); +>a : any +>f8(a) : any +>f8 : (x: () => T) => T +>a : any + +var a = f9(a); +>a : any +>f9(a) : any +>f9 : (x: new () => T) => T +>a : any + +var a = f10(a); +>a : any +>f10(a) : any +>f10 : (x: { [x: string]: T; }) => T +>a : any + +var a = f11(a); +>a : any +>f11(a) : any +>f11 : (x: { [x: number]: T; }) => T +>a : any + +var t = f12(a); +>t : [any, any] +>f12(a) : [any, any] +>f12 : (x: T | U) => [T, U] +>a : any + +var t = f13(a); +>t : [any, any] +>f13(a) : [any, any] +>f13 : (x: T & U) => [T, U] +>a : any + +var t = f14(a); +>t : [any, any] +>f14(a) : [any, any] +>f14 : (x: { a: T | U; b: U & T; }) => [T, U] +>a : any + +var a = f15(a); +>a : any +>f15(a) : any +>f15 : (x: I) => T +>a : any + +var a = f16(a); +>a : any +>f16(a) : any +>f16 : (x: Partial) => T +>a : any + +var a = f17(a); +>a : any +>f17(a) : any +>f17 : (x: { [P in keyof T]: K; }) => T +>a : any + +var a = f18(a); +>a : any +>f18(a) : any +>f18 : (x: { [P in K]: T[P]; }) => T +>a : any + +var a = f19(a, a); +>a : any +>f19(a, a) : any +>f19 : (k: K, x: T[K]) => T +>a : any +>a : any + diff --git a/tests/cases/conformance/salsa/inferingFromAny.ts b/tests/cases/conformance/salsa/inferingFromAny.ts new file mode 100644 index 00000000000..60519b2a5b6 --- /dev/null +++ b/tests/cases/conformance/salsa/inferingFromAny.ts @@ -0,0 +1,47 @@ +// @allowJs: true +// @noEmit: true + +// @fileName: a.ts +var a: any; +var t: [any, any]; +declare function f1(t: T): T +declare function f2(t: T[]): T; +declare function f3(t: [T, U]): [T, U]; +declare function f4(x: { bar: T; baz: T }): T; +declare function f5(x: (a: T) => void): T; +declare function f6(x: new (a: T) => {}): T; +declare function f7(x: (a: any) => a is T): T; +declare function f8(x: () => T): T; +declare function f9(x: new () => T): T; +declare function f10(x: { [x: string]: T }): T; +declare function f11(x: { [x: number]: T }): T; +declare function f12(x: T | U): [T, U]; +declare function f13(x: T & U): [T, U]; +declare function f14(x: { a: T | U, b: U & T }): [T, U]; +interface I { } +declare function f15(x: I): T; +declare function f16(x: Partial): T; +declare function f17(x: {[P in keyof T]: K}): T; +declare function f18(x: {[P in K]: T[P]}): T; +declare function f19(k: K, x: T[K]): T; + +// @fileName: a.js +var a = f1(a); +var a = f2(a); +var t = f3(a); +var a = f4(a); +var a = f5(a); +var a = f6(a); +var a = f7(a); +var a = f8(a); +var a = f9(a); +var a = f10(a); +var a = f11(a); +var t = f12(a); +var t = f13(a); +var t = f14(a); +var a = f15(a); +var a = f16(a); +var a = f17(a); +var a = f18(a); +var a = f19(a, a); \ No newline at end of file From 6a2d2608c355cab6a6b0143be93cfc86f4fdfe58 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 6 Mar 2017 13:36:54 -0800 Subject: [PATCH 104/167] Update baselines --- tests/baselines/reference/importHelpersInIsolatedModules.js | 1 - tests/baselines/reference/isolatedModulesPlainFile-AMD.js | 1 - tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js | 1 - tests/baselines/reference/isolatedModulesPlainFile-UMD.js | 1 - .../transpile/Does not generate semantic diagnostics.js | 1 - .../transpile/Generates expected syntactic diagnostics.js | 1 - tests/baselines/reference/transpile/Generates module output.js | 1 - .../Generates no diagnostics for missing file references.js | 1 - .../transpile/Generates no diagnostics with valid inputs.js | 1 - .../transpile/No extra errors for file without extension.js | 1 - ...an error when compiler-options module-kind is out-of-range.js | 1 - ... error when compiler-options target-script is out-of-range.js | 1 - .../reference/transpile/Support options with lib values.js | 1 - .../reference/transpile/Support options with types values.js | 1 - .../reference/transpile/Supports backslashes in file name.js | 1 - tests/baselines/reference/transpile/Supports setting allowJs.js | 1 - .../transpile/Supports setting allowSyntheticDefaultImports.js | 1 - .../reference/transpile/Supports setting allowUnreachableCode.js | 1 - .../reference/transpile/Supports setting allowUnusedLabels.js | 1 - .../reference/transpile/Supports setting alwaysStrict.js | 1 - tests/baselines/reference/transpile/Supports setting baseUrl.js | 1 - tests/baselines/reference/transpile/Supports setting charset.js | 1 - .../reference/transpile/Supports setting declaration.js | 1 - .../reference/transpile/Supports setting declarationDir.js | 1 - tests/baselines/reference/transpile/Supports setting emitBOM.js | 1 - .../transpile/Supports setting emitDecoratorMetadata.js | 1 - .../transpile/Supports setting experimentalDecorators.js | 1 - .../Supports setting forceConsistentCasingInFileNames.js | 1 - .../reference/transpile/Supports setting isolatedModules.js | 1 - tests/baselines/reference/transpile/Supports setting jsx.js | 1 - .../baselines/reference/transpile/Supports setting jsxFactory.js | 1 - tests/baselines/reference/transpile/Supports setting lib.js | 1 - tests/baselines/reference/transpile/Supports setting locale.js | 1 - tests/baselines/reference/transpile/Supports setting module.js | 1 - .../reference/transpile/Supports setting moduleResolution.js | 1 - tests/baselines/reference/transpile/Supports setting newLine.js | 1 - tests/baselines/reference/transpile/Supports setting noEmit.js | 1 - .../reference/transpile/Supports setting noEmitHelpers.js | 1 - .../reference/transpile/Supports setting noEmitOnError.js | 1 - .../reference/transpile/Supports setting noErrorTruncation.js | 1 - .../transpile/Supports setting noFallthroughCasesInSwitch.js | 1 - .../reference/transpile/Supports setting noImplicitAny.js | 1 - .../reference/transpile/Supports setting noImplicitReturns.js | 1 - .../reference/transpile/Supports setting noImplicitThis.js | 1 - .../reference/transpile/Supports setting noImplicitUseStrict.js | 1 - tests/baselines/reference/transpile/Supports setting noLib.js | 1 - .../baselines/reference/transpile/Supports setting noResolve.js | 1 - tests/baselines/reference/transpile/Supports setting out.js | 1 - tests/baselines/reference/transpile/Supports setting outDir.js | 1 - tests/baselines/reference/transpile/Supports setting outFile.js | 1 - tests/baselines/reference/transpile/Supports setting paths.js | 1 - .../reference/transpile/Supports setting preserveConstEnums.js | 1 - .../reference/transpile/Supports setting reactNamespace.js | 1 - .../reference/transpile/Supports setting removeComments.js | 1 - tests/baselines/reference/transpile/Supports setting rootDir.js | 1 - tests/baselines/reference/transpile/Supports setting rootDirs.js | 1 - .../reference/transpile/Supports setting skipDefaultLibCheck.js | 1 - .../reference/transpile/Supports setting skipLibCheck.js | 1 - .../reference/transpile/Supports setting strictNullChecks.js | 1 - .../reference/transpile/Supports setting stripInternal.js | 1 - .../transpile/Supports setting suppressExcessPropertyErrors.js | 1 - .../transpile/Supports setting suppressImplicitAnyIndexErrors.js | 1 - .../baselines/reference/transpile/Supports setting typeRoots.js | 1 - tests/baselines/reference/transpile/Supports setting types.js | 1 - .../baselines/reference/transpile/Supports urls in file name.js | 1 - .../reference/transpile/Uses correct newLine character.js | 1 - tests/baselines/reference/transpile/transpile .js files.js | 1 - .../transpile/transpile file as tsx if jsx is specified.js | 1 - 68 files changed, 68 deletions(-) diff --git a/tests/baselines/reference/importHelpersInIsolatedModules.js b/tests/baselines/reference/importHelpersInIsolatedModules.js index 72a91ac365e..454fde430d3 100644 --- a/tests/baselines/reference/importHelpersInIsolatedModules.js +++ b/tests/baselines/reference/importHelpersInIsolatedModules.js @@ -69,7 +69,6 @@ C = tslib_1.__decorate([ ], C); //// [script.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var A = (function () { function A() { diff --git a/tests/baselines/reference/isolatedModulesPlainFile-AMD.js b/tests/baselines/reference/isolatedModulesPlainFile-AMD.js index 4ed1fdf2c77..1e45ee159d6 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-AMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-AMD.js @@ -7,6 +7,5 @@ run(1); //// [isolatedModulesPlainFile-AMD.js] define(["require", "exports"], function (require, exports) { "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); run(1); }); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js index 38739a700ef..f40d2173685 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js @@ -6,5 +6,4 @@ run(1); //// [isolatedModulesPlainFile-CommonJS.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); run(1); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js index f37962a84ab..ece949b9100 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js @@ -15,6 +15,5 @@ run(1); } })(function (require, exports) { "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); run(1); }); diff --git a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js index 4571caffa31..61a703e13bb 100644 --- a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js +++ b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js index 4d133b7655c..9d108d63313 100644 --- a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js +++ b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js @@ -1,5 +1,4 @@ "use strict"; -exports.__esModule = true; a; b; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates module output.js b/tests/baselines/reference/transpile/Generates module output.js index 2c7bb7add09..9eadd1f2717 100644 --- a/tests/baselines/reference/transpile/Generates module output.js +++ b/tests/baselines/reference/transpile/Generates module output.js @@ -1,6 +1,5 @@ define(["require", "exports"], function (require, exports) { "use strict"; - exports.__esModule = true; var x = 0; }); //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js index 04ba1d12e5e..88d98628eee 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js @@ -1,5 +1,4 @@ "use strict"; -exports.__esModule = true; /// var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js index 4571caffa31..61a703e13bb 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/No extra errors for file without extension.js b/tests/baselines/reference/transpile/No extra errors for file without extension.js index 4571caffa31..61a703e13bb 100644 --- a/tests/baselines/reference/transpile/No extra errors for file without extension.js +++ b/tests/baselines/reference/transpile/No extra errors for file without extension.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js index e9493d9d591..1ceb1bcd146 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js @@ -1,3 +1,2 @@ "use strict"; -exports.__esModule = true; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js index e9493d9d591..1ceb1bcd146 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js @@ -1,3 +1,2 @@ "use strict"; -exports.__esModule = true; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with lib values.js b/tests/baselines/reference/transpile/Support options with lib values.js index 72e077de381..36c68f08b9f 100644 --- a/tests/baselines/reference/transpile/Support options with lib values.js +++ b/tests/baselines/reference/transpile/Support options with lib values.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with types values.js b/tests/baselines/reference/transpile/Support options with types values.js index 72e077de381..36c68f08b9f 100644 --- a/tests/baselines/reference/transpile/Support options with types values.js +++ b/tests/baselines/reference/transpile/Support options with types values.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports backslashes in file name.js b/tests/baselines/reference/transpile/Supports backslashes in file name.js index 8ef38d2b617..942449753b0 100644 --- a/tests/baselines/reference/transpile/Supports backslashes in file name.js +++ b/tests/baselines/reference/transpile/Supports backslashes in file name.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x; //# sourceMappingURL=b.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowJs.js b/tests/baselines/reference/transpile/Supports setting allowJs.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting allowJs.js +++ b/tests/baselines/reference/transpile/Supports setting allowJs.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js +++ b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting alwaysStrict.js b/tests/baselines/reference/transpile/Supports setting alwaysStrict.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting alwaysStrict.js +++ b/tests/baselines/reference/transpile/Supports setting alwaysStrict.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting baseUrl.js b/tests/baselines/reference/transpile/Supports setting baseUrl.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting baseUrl.js +++ b/tests/baselines/reference/transpile/Supports setting baseUrl.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting charset.js b/tests/baselines/reference/transpile/Supports setting charset.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting charset.js +++ b/tests/baselines/reference/transpile/Supports setting charset.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declaration.js b/tests/baselines/reference/transpile/Supports setting declaration.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting declaration.js +++ b/tests/baselines/reference/transpile/Supports setting declaration.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declarationDir.js b/tests/baselines/reference/transpile/Supports setting declarationDir.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting declarationDir.js +++ b/tests/baselines/reference/transpile/Supports setting declarationDir.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitBOM.js b/tests/baselines/reference/transpile/Supports setting emitBOM.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting emitBOM.js +++ b/tests/baselines/reference/transpile/Supports setting emitBOM.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js +++ b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js +++ b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js +++ b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting isolatedModules.js b/tests/baselines/reference/transpile/Supports setting isolatedModules.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting isolatedModules.js +++ b/tests/baselines/reference/transpile/Supports setting isolatedModules.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsx.js b/tests/baselines/reference/transpile/Supports setting jsx.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting jsx.js +++ b/tests/baselines/reference/transpile/Supports setting jsx.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsxFactory.js b/tests/baselines/reference/transpile/Supports setting jsxFactory.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting jsxFactory.js +++ b/tests/baselines/reference/transpile/Supports setting jsxFactory.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting lib.js b/tests/baselines/reference/transpile/Supports setting lib.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting lib.js +++ b/tests/baselines/reference/transpile/Supports setting lib.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting locale.js b/tests/baselines/reference/transpile/Supports setting locale.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting locale.js +++ b/tests/baselines/reference/transpile/Supports setting locale.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting module.js b/tests/baselines/reference/transpile/Supports setting module.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting module.js +++ b/tests/baselines/reference/transpile/Supports setting module.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting moduleResolution.js b/tests/baselines/reference/transpile/Supports setting moduleResolution.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting moduleResolution.js +++ b/tests/baselines/reference/transpile/Supports setting moduleResolution.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting newLine.js b/tests/baselines/reference/transpile/Supports setting newLine.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting newLine.js +++ b/tests/baselines/reference/transpile/Supports setting newLine.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmit.js b/tests/baselines/reference/transpile/Supports setting noEmit.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmit.js +++ b/tests/baselines/reference/transpile/Supports setting noEmit.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js +++ b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js +++ b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js b/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js index 8124d51fde3..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js @@ -1,3 +1,2 @@ -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noLib.js b/tests/baselines/reference/transpile/Supports setting noLib.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noLib.js +++ b/tests/baselines/reference/transpile/Supports setting noLib.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noResolve.js b/tests/baselines/reference/transpile/Supports setting noResolve.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting noResolve.js +++ b/tests/baselines/reference/transpile/Supports setting noResolve.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting out.js b/tests/baselines/reference/transpile/Supports setting out.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting out.js +++ b/tests/baselines/reference/transpile/Supports setting out.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outDir.js b/tests/baselines/reference/transpile/Supports setting outDir.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting outDir.js +++ b/tests/baselines/reference/transpile/Supports setting outDir.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outFile.js b/tests/baselines/reference/transpile/Supports setting outFile.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting outFile.js +++ b/tests/baselines/reference/transpile/Supports setting outFile.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting paths.js b/tests/baselines/reference/transpile/Supports setting paths.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting paths.js +++ b/tests/baselines/reference/transpile/Supports setting paths.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js +++ b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting reactNamespace.js b/tests/baselines/reference/transpile/Supports setting reactNamespace.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting reactNamespace.js +++ b/tests/baselines/reference/transpile/Supports setting reactNamespace.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting removeComments.js b/tests/baselines/reference/transpile/Supports setting removeComments.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting removeComments.js +++ b/tests/baselines/reference/transpile/Supports setting removeComments.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDir.js b/tests/baselines/reference/transpile/Supports setting rootDir.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDir.js +++ b/tests/baselines/reference/transpile/Supports setting rootDir.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDirs.js b/tests/baselines/reference/transpile/Supports setting rootDirs.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDirs.js +++ b/tests/baselines/reference/transpile/Supports setting rootDirs.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js +++ b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting stripInternal.js b/tests/baselines/reference/transpile/Supports setting stripInternal.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting stripInternal.js +++ b/tests/baselines/reference/transpile/Supports setting stripInternal.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting typeRoots.js b/tests/baselines/reference/transpile/Supports setting typeRoots.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting typeRoots.js +++ b/tests/baselines/reference/transpile/Supports setting typeRoots.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting types.js b/tests/baselines/reference/transpile/Supports setting types.js index f960e73bcb8..8d91090453b 100644 --- a/tests/baselines/reference/transpile/Supports setting types.js +++ b/tests/baselines/reference/transpile/Supports setting types.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports urls in file name.js b/tests/baselines/reference/transpile/Supports urls in file name.js index 933981306d2..3923d3c9a41 100644 --- a/tests/baselines/reference/transpile/Supports urls in file name.js +++ b/tests/baselines/reference/transpile/Supports urls in file name.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Uses correct newLine character.js b/tests/baselines/reference/transpile/Uses correct newLine character.js index 04042012d18..bab9c3c4443 100644 --- a/tests/baselines/reference/transpile/Uses correct newLine character.js +++ b/tests/baselines/reference/transpile/Uses correct newLine character.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile .js files.js b/tests/baselines/reference/transpile/transpile .js files.js index b9048bd515d..c17099d84ba 100644 --- a/tests/baselines/reference/transpile/transpile .js files.js +++ b/tests/baselines/reference/transpile/transpile .js files.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js index 2a73615e476..baa27ee64ce 100644 --- a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js +++ b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js @@ -1,4 +1,3 @@ "use strict"; -exports.__esModule = true; var x = React.createElement("div", null); //# sourceMappingURL=file.js.map \ No newline at end of file From eaca169b114047cb6c663fbbee4ade4b493a031f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 6 Mar 2017 16:21:54 -0800 Subject: [PATCH 105/167] Remove optionality from the initial type of default-valued parameters When narrowing, remove optionality from the initial type of parameters with initialisers. Note that the type of the initialiser is not used; its presence just means that the initial type of the parameter can't contain undefined. It could contain any other member of a declared union type. --- src/compiler/checker.ts | 43 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5d45af57343..f17f079008b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3368,16 +3368,6 @@ namespace ts { return strictNullChecks && optional ? includeFalsyTypes(type, TypeFlags.Undefined) : type; } - /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ - function removeOptionalityFromAnnotation(annotatedType: Type, declaration: VariableLikeDeclaration): Type { - const annotationIncludesUndefined = strictNullChecks && - declaration.kind === SyntaxKind.Parameter && - declaration.initializer && - getFalsyFlags(annotatedType) & TypeFlags.Undefined && - !(getFalsyFlags(checkExpression(declaration.initializer)) & TypeFlags.Undefined); - return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; - } - // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration, includeOptionality: boolean): Type { if (declaration.flags & NodeFlags.JavaScriptFile) { @@ -3412,7 +3402,7 @@ namespace ts { // Use type from type annotation if one is present if (declaration.type) { - const declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + const declaredType = getTypeFromTypeNode(declaration.type); return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } @@ -10248,14 +10238,12 @@ namespace ts { return false; } - function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, flowContainer: Node) { + function isFlowNarrowable(reference: Node, type: Type, couldBeUninitialized?: boolean) { + return reference.flowNode && (type.flags & TypeFlags.Narrowable || couldBeUninitialized); + } + + function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node) { let key: string; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) { - return declaredType; - } - const initialType = assumeInitialized ? declaredType : - declaredType === autoType || declaredType === autoArrayType ? undefinedType : - includeFalsyTypes(declaredType, TypeFlags.Undefined); const visitedFlowStart = visitedFlowCount; const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -10934,6 +10922,16 @@ namespace ts { return symbol.flags & SymbolFlags.Variable && (getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; } + /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ + function removeOptionalityFromDeclaredType(declaredType: Type, declaration: VariableLikeDeclaration): Type { + const annotationIncludesUndefined = strictNullChecks && + declaration.kind === SyntaxKind.Parameter && + declaration.initializer && + getFalsyFlags(declaredType) & TypeFlags.Undefined && + !(getFalsyFlags(checkExpression(declaration.initializer)) & TypeFlags.Undefined); + return annotationIncludesUndefined ? getNonNullableType(declaredType) : declaredType; + } + function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { @@ -11052,7 +11050,10 @@ namespace ts { const assumeInitialized = isParameter || isOuterVariable || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isInTypeQuery(node)) || isInAmbientContext(declaration); - const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); + const initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, getRootDeclaration(declaration) as VariableLikeDeclaration) : type) : + type === autoType || type === autoArrayType ? undefinedType : + includeFalsyTypes(type, TypeFlags.Undefined); + const flowType = isFlowNarrowable(node, type, !assumeInitialized) ? getFlowTypeOfReference(node, type, initialType, flowContainer) : type; // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. @@ -11318,7 +11319,7 @@ namespace ts { if (isClassLike(container.parent)) { const symbol = getSymbolOfNode(container.parent); const type = hasModifier(container, ModifierFlags.Static) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; - return getFlowTypeOfReference(node, type, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + return isFlowNarrowable(node, type) ? getFlowTypeOfReference(node, type) : type; } if (isInJavaScriptFile(node)) { @@ -13309,7 +13310,7 @@ namespace ts { !(prop.flags & SymbolFlags.Method && propType.flags & TypeFlags.Union)) { return propType; } - const flowType = getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + const flowType = isFlowNarrowable(node, propType) ? getFlowTypeOfReference(node, propType) : propType; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } From 533ce824e8235e7545d9d107fe3112c77b6e3cc3 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 6 Mar 2017 16:24:44 -0800 Subject: [PATCH 106/167] Add assignability tests for initialised parameters --- ...ameterAddsUndefinedWithStrictNullChecks.js | 4 ++ ...rAddsUndefinedWithStrictNullChecks.symbols | 40 +++++++++++-------- ...terAddsUndefinedWithStrictNullChecks.types | 12 +++++- ...ameterAddsUndefinedWithStrictNullChecks.ts | 2 + 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js index 329c2fb19ce..7f9cf553fe4 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js @@ -18,10 +18,12 @@ function foo2(x = "string", b: number) { function foo3(x: string | undefined = "string", b: number) { x.length; // ok, should be string + x = undefined; } function foo4(x: string | undefined = undefined, b: number) { x; // should be string | undefined + x = undefined; } @@ -72,10 +74,12 @@ function foo2(x, b) { function foo3(x, b) { if (x === void 0) { x = "string"; } x.length; // ok, should be string + x = undefined; } function foo4(x, b) { if (x === void 0) { x = undefined; } x; // should be string | undefined + x = undefined; } // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 foo1(undefined, 1); diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols index fb0fce7dc7f..a484377f3f4 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols @@ -66,16 +66,24 @@ function foo3(x: string | undefined = "string", b: number) { >x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 17, 14)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x = undefined; +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 17, 14)) +>undefined : Symbol(undefined) } function foo4(x: string | undefined = undefined, b: number) { ->foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 19, 1)) ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 21, 14)) +>foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 20, 1)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 22, 14)) >undefined : Symbol(undefined) ->b : Symbol(b, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 21, 48)) +>b : Symbol(b, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 22, 48)) x; // should be string | undefined ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 21, 14)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 22, 14)) + + x = undefined; +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 22, 14)) +>undefined : Symbol(undefined) } @@ -94,40 +102,40 @@ foo3(undefined, 1); >undefined : Symbol(undefined) foo4(undefined, 1); ->foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 19, 1)) +>foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 20, 1)) >undefined : Symbol(undefined) function removeUndefinedButNotFalse(x = true) { ->removeUndefinedButNotFalse : Symbol(removeUndefinedButNotFalse, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 31, 19)) ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 34, 36)) +>removeUndefinedButNotFalse : Symbol(removeUndefinedButNotFalse, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 33, 19)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 36, 36)) if (x === false) { ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 34, 36)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 36, 36)) return x; ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 34, 36)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 36, 36)) } } declare const cond: boolean; ->cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 13)) +>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 42, 13)) function removeNothing(y = cond ? true : undefined) { ->removeNothing : Symbol(removeNothing, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 28)) ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) ->cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 13)) +>removeNothing : Symbol(removeNothing, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 42, 28)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23)) +>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 42, 13)) >undefined : Symbol(undefined) if (y !== undefined) { ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23)) >undefined : Symbol(undefined) if (y === false) { ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23)) return y; ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23)) } } return true; diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types index d95f9259891..54b9cdf2a9b 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types @@ -86,7 +86,7 @@ function foo2(x = "string", b: number) { function foo3(x: string | undefined = "string", b: number) { >foo3 : (x: string | undefined, b: number) => void ->x : string +>x : string | undefined >"string" : "string" >b : number @@ -94,6 +94,11 @@ function foo3(x: string | undefined = "string", b: number) { >x.length : number >x : string >length : number + + x = undefined; +>x = undefined : undefined +>x : string | undefined +>undefined : undefined } function foo4(x: string | undefined = undefined, b: number) { @@ -104,6 +109,11 @@ function foo4(x: string | undefined = undefined, b: number) { x; // should be string | undefined >x : string | undefined + + x = undefined; +>x = undefined : undefined +>x : string | undefined +>undefined : undefined } diff --git a/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts b/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts index 8abea19f6cd..04a9e668b32 100644 --- a/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts +++ b/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts @@ -19,10 +19,12 @@ function foo2(x = "string", b: number) { function foo3(x: string | undefined = "string", b: number) { x.length; // ok, should be string + x = undefined; } function foo4(x: string | undefined = undefined, b: number) { x; // should be string | undefined + x = undefined; } From 8d9692129f42eee650c1b69be98b8a970b79e0e9 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 6 Mar 2017 16:53:39 -0800 Subject: [PATCH 107/167] Fix typo --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa8d42dd3c1..0db2a792712 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3472,7 +3472,7 @@ namespace ts { return undefined; } - function getWidenedTypeFromJSSpecialPropetyDeclarations(symbol: Symbol) { + function getWidenedTypeFromJSSpecialPropertyDeclarations(symbol: Symbol) { const types: Type[] = []; let definedInConstructor = false; let definedInMethod = false; @@ -3663,7 +3663,7 @@ namespace ts { // * className.prototype.method = expr if (declaration.kind === SyntaxKind.BinaryExpression || declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { - type = getWidenedTypeFromJSSpecialPropetyDeclarations(symbol); + type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); From 1f46dd9949e3ad3a9d50b324d40cad1db861e851 Mon Sep 17 00:00:00 2001 From: Mike Busyrev Date: Tue, 7 Mar 2017 19:35:57 +0300 Subject: [PATCH 108/167] FIX: #14507 Function parameter default value wrongly emmited by Printer --- src/compiler/emitter.ts | 2 +- src/harness/unittests/printer.ts | 3 +++ .../reference/printerApi/printsFileCorrectly.default.js | 2 ++ .../reference/printerApi/printsFileCorrectly.removeComments.js | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ee224befd45..05b40472c3c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -819,8 +819,8 @@ namespace ts { writeIfPresent(node.dotDotDotToken, "..."); emit(node.name); writeIfPresent(node.questionToken, "?"); - emitExpressionWithPrefix(" = ", node.initializer); emitWithPrefix(": ", node.type); + emitExpressionWithPrefix(" = ", node.initializer); } function emitDecorator(decorator: Decorator) { diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index 1a5a5a12f9e..e5167b592c2 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -45,6 +45,9 @@ namespace ts { // comment9 console.log(1 + 2); + + // comment10 + function functionWithDefaultArgValue(argument: string = "defaultValue"): void { } `, ScriptTarget.ES2015); printsCorrectly("default", {}, printer => printer.printFile(sourceFile)); diff --git a/tests/baselines/reference/printerApi/printsFileCorrectly.default.js b/tests/baselines/reference/printerApi/printsFileCorrectly.default.js index 9bff9d656b3..576c8bf68ed 100644 --- a/tests/baselines/reference/printerApi/printsFileCorrectly.default.js +++ b/tests/baselines/reference/printerApi/printsFileCorrectly.default.js @@ -23,3 +23,5 @@ const enum E2 { } // comment9 console.log(1 + 2); +// comment10 +function functionWithDefaultArgValue(argument: string = "defaultValue"): void { } diff --git a/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js b/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js index b511aff5e78..8e839c069a9 100644 --- a/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js +++ b/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js @@ -15,3 +15,4 @@ const enum E2 { second } console.log(1 + 2); +function functionWithDefaultArgValue(argument: string = "defaultValue"): void { } From fa02c808d1f3ba554726aa003793fd5ddef92af0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 7 Mar 2017 09:07:34 -0800 Subject: [PATCH 109/167] Remove null and undefined from contextual 'this' type --- src/compiler/checker.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 04e1f5911cd..22c294d0243 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11601,7 +11601,7 @@ namespace ts { } } } - if (compilerOptions.noImplicitThis) { + if (noImplicitThis) { const containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { // We have an object literal method. Check if the containing object literal has a contextual type @@ -11622,9 +11622,9 @@ namespace ts { type = getApparentTypeOfContextualType(literal); } // There was no contextual ThisType for the containing object literal, so the contextual type - // for 'this' is the contextual type for the containing object literal or the type of the object - // literal itself. - return contextualType || checkExpressionCached(containingLiteral); + // for 'this' is the non-null form of the contextual type for the containing object literal or + // the type of the object literal itself. + return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. From 0ac92b47065b4cce27aea38b932f123c6f8aa8fa Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 7 Mar 2017 09:07:53 -0800 Subject: [PATCH 110/167] Add tests --- .../thisType/thisTypeInObjectLiterals2.ts | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts index d476679aef1..27861f81da6 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals2.ts @@ -1,7 +1,5 @@ // @declaration: true -// @strictNullChecks: true -// @noImplicitAny: true -// @noImplicitThis: true +// @strict: true // @target: es5 // In methods of an object literal with no contextual type, 'this' has the type @@ -51,6 +49,42 @@ let p1: Point = { } }; +let p2: Point | null = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + +let p3: Point | undefined = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + +let p4: Point | null | undefined = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + declare function f1(p: Point): void; f1({ @@ -65,6 +99,20 @@ f1({ } }); +declare function f2(p: Point | null | undefined): void; + +f2({ + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}); + // In methods of an object literal with a contextual type that includes some // ThisType, 'this' is of type T. From a4d2c572bf4b8387c565d10c26e8b25b73783bf9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 7 Mar 2017 09:08:02 -0800 Subject: [PATCH 111/167] Accept new baselines --- .../reference/thisTypeInObjectLiterals2.js | 99 +++ .../thisTypeInObjectLiterals2.symbols | 648 +++++++++++------- .../reference/thisTypeInObjectLiterals2.types | 208 ++++++ 3 files changed, 719 insertions(+), 236 deletions(-) diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.js b/tests/baselines/reference/thisTypeInObjectLiterals2.js index 88cbd2555f6..a9b666fda8f 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals2.js +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.js @@ -47,6 +47,42 @@ let p1: Point = { } }; +let p2: Point | null = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + +let p3: Point | undefined = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + +let p4: Point | null | undefined = { + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; + declare function f1(p: Point): void; f1({ @@ -61,6 +97,20 @@ f1({ } }); +declare function f2(p: Point | null | undefined): void; + +f2({ + x: 10, + y: 20, + moveBy(dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}); + // In methods of an object literal with a contextual type that includes some // ThisType, 'this' is of type T. @@ -196,6 +246,7 @@ vue.hello; //// [thisTypeInObjectLiterals2.js] // In methods of an object literal with no contextual type, 'this' has the type // of the object literal. +"use strict"; var obj1 = { a: 1, f: function () { @@ -228,6 +279,39 @@ var p1 = { } } }; +var p2 = { + x: 10, + y: 20, + moveBy: function (dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; +var p3 = { + x: 10, + y: 20, + moveBy: function (dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; +var p4 = { + x: 10, + y: 20, + moveBy: function (dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}; f1({ x: 10, y: 20, @@ -239,6 +323,17 @@ f1({ } } }); +f2({ + x: 10, + y: 20, + moveBy: function (dx, dy, dz) { + this.x += dx; + this.y += dy; + if (this.z && dz) { + this.z += dz; + } + } +}); var x1 = makeObject({ data: { x: 0, y: 0 }, methods: { @@ -328,7 +423,11 @@ declare type Point = { moveBy(dx: number, dy: number, dz?: number): void; }; declare let p1: Point; +declare let p2: Point | null; +declare let p3: Point | undefined; +declare let p4: Point | null | undefined; declare function f1(p: Point): void; +declare function f2(p: Point | null | undefined): void; declare type ObjectDescriptor = { data?: D; methods?: M & ThisType; diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.symbols b/tests/baselines/reference/thisTypeInObjectLiterals2.symbols index e7412ab487f..4c3e60c7536 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals2.symbols +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.symbols @@ -128,49 +128,225 @@ let p1: Point = { } }; -declare function f1(p: Point): void; ->f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 46, 2)) ->p : Symbol(p, Decl(thisTypeInObjectLiterals2.ts, 48, 20)) +let p2: Point | null = { +>p2 : Symbol(p2, Decl(thisTypeInObjectLiterals2.ts, 48, 3)) >Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) -f1({ ->f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 46, 2)) - x: 10, ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 50, 4)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 48, 24)) y: 20, ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 51, 10)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 49, 10)) moveBy(dx, dy, dz) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 52, 10)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 53, 11)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 53, 14)) ->dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 53, 18)) +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 50, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 51, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 51, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 51, 18)) this.x += dx; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 53, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 51, 11)) this.y += dy; >this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 53, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 51, 14)) if (this.z && dz) { >this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) ->dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 53, 18)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 51, 18)) this.z += dz; >this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) ->dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 53, 18)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 51, 18)) + } + } +}; + +let p3: Point | undefined = { +>p3 : Symbol(p3, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 60, 29)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 61, 10)) + + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 62, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 63, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 63, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 63, 18)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 63, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 63, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 63, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 63, 18)) + } + } +}; + +let p4: Point | null | undefined = { +>p4 : Symbol(p4, Decl(thisTypeInObjectLiterals2.ts, 72, 3)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 72, 36)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 10)) + + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 74, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 75, 18)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 75, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 75, 18)) + } + } +}; + +declare function f1(p: Point): void; +>f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 82, 2)) +>p : Symbol(p, Decl(thisTypeInObjectLiterals2.ts, 84, 20)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + +f1({ +>f1 : Symbol(f1, Decl(thisTypeInObjectLiterals2.ts, 82, 2)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 86, 4)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 87, 10)) + + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 88, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 89, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 89, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 89, 18)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 89, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 89, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 89, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 89, 18)) + } + } +}); + +declare function f2(p: Point | null | undefined): void; +>f2 : Symbol(f2, Decl(thisTypeInObjectLiterals2.ts, 96, 3)) +>p : Symbol(p, Decl(thisTypeInObjectLiterals2.ts, 98, 20)) +>Point : Symbol(Point, Decl(thisTypeInObjectLiterals2.ts, 24, 2)) + +f2({ +>f2 : Symbol(f2, Decl(thisTypeInObjectLiterals2.ts, 96, 3)) + + x: 10, +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 100, 4)) + + y: 20, +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 101, 10)) + + moveBy(dx, dy, dz) { +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 102, 10)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 103, 11)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 103, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 103, 18)) + + this.x += dx; +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 103, 11)) + + this.y += dy; +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 30, 14)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 103, 14)) + + if (this.z && dz) { +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 103, 18)) + + this.z += dz; +>this.z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) +>z : Symbol(z, Decl(thisTypeInObjectLiterals2.ts, 31, 14)) +>dz : Symbol(dz, Decl(thisTypeInObjectLiterals2.ts, 103, 18)) } } }); @@ -179,59 +355,59 @@ f1({ // ThisType, 'this' is of type T. type ObjectDescriptor = { ->ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 65, 22)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 65, 24)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 110, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 115, 22)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 115, 24)) data?: D; ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 65, 31)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 65, 22)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 115, 31)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 115, 22)) methods?: M & ThisType; // Type of 'this' in methods is D & M ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 66, 13)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 65, 24)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 116, 13)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 115, 24)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 65, 22)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 65, 24)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 115, 22)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 115, 24)) } declare function makeObject(desc: ObjectDescriptor): D & M; ->makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 68, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 70, 28)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 70, 30)) ->desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 70, 34)) ->ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 70, 28)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 70, 30)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 70, 28)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 70, 30)) +>makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 118, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 120, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 120, 30)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 120, 34)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 110, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 120, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 120, 30)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 120, 28)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 120, 30)) let x1 = makeObject({ ->x1 : Symbol(x1, Decl(thisTypeInObjectLiterals2.ts, 72, 3)) ->makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 68, 1)) +>x1 : Symbol(x1, Decl(thisTypeInObjectLiterals2.ts, 122, 3)) +>makeObject : Symbol(makeObject, Decl(thisTypeInObjectLiterals2.ts, 118, 1)) data: { x: 0, y: 0 }, ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 72, 21)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 73, 11)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 17)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 122, 21)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 123, 11)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 123, 17)) methods: { ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 73, 25)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 123, 25)) moveBy(dx: number, dy: number) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 74, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 15)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 26)) +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 124, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 125, 15)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 125, 26)) this.x += dx; // Strongly typed this ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 73, 11)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 73, 11)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 75, 15)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 123, 11)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 123, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 125, 15)) this.y += dy; // Strongly typed this ->this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 17)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 73, 17)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 75, 26)) +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 123, 17)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 123, 17)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 125, 26)) } } }); @@ -240,59 +416,59 @@ let x1 = makeObject({ // some ThisType, 'this' is of type T. type ObjectDescriptor2 = ThisType & { ->ObjectDescriptor2 : Symbol(ObjectDescriptor2, Decl(thisTypeInObjectLiterals2.ts, 80, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 85, 23)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 85, 25)) +>ObjectDescriptor2 : Symbol(ObjectDescriptor2, Decl(thisTypeInObjectLiterals2.ts, 130, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 135, 23)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 135, 25)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 85, 23)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 85, 25)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 135, 23)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 135, 25)) data?: D; ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 85, 50)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 85, 23)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 135, 50)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 135, 23)) methods?: M; ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 86, 13)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 85, 25)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 136, 13)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 135, 25)) } declare function makeObject2(desc: ObjectDescriptor): D & M; ->makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 88, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 90, 29)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 90, 31)) ->desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 90, 35)) ->ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 60, 3)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 90, 29)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 90, 31)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 90, 29)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 90, 31)) +>makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 138, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 140, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 140, 31)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 140, 35)) +>ObjectDescriptor : Symbol(ObjectDescriptor, Decl(thisTypeInObjectLiterals2.ts, 110, 3)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 140, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 140, 31)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 140, 29)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 140, 31)) let x2 = makeObject2({ ->x2 : Symbol(x2, Decl(thisTypeInObjectLiterals2.ts, 92, 3)) ->makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 88, 1)) +>x2 : Symbol(x2, Decl(thisTypeInObjectLiterals2.ts, 142, 3)) +>makeObject2 : Symbol(makeObject2, Decl(thisTypeInObjectLiterals2.ts, 138, 1)) data: { x: 0, y: 0 }, ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 92, 22)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 93, 11)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 93, 17)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 142, 22)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 143, 11)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 143, 17)) methods: { ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 93, 25)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 143, 25)) moveBy(dx: number, dy: number) { ->moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 94, 14)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 95, 15)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 95, 26)) +>moveBy : Symbol(moveBy, Decl(thisTypeInObjectLiterals2.ts, 144, 14)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 145, 15)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 145, 26)) this.x += dx; // Strongly typed this ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 93, 11)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 93, 11)) ->dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 95, 15)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 143, 11)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 143, 11)) +>dx : Symbol(dx, Decl(thisTypeInObjectLiterals2.ts, 145, 15)) this.y += dy; // Strongly typed this ->this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 93, 17)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 93, 17)) ->dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 95, 26)) +>this.y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 143, 17)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 143, 17)) +>dy : Symbol(dy, Decl(thisTypeInObjectLiterals2.ts, 145, 26)) } } }); @@ -300,89 +476,89 @@ let x2 = makeObject2({ // Check pattern similar to Object.defineProperty and Object.defineProperties type PropDesc = { ->PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 100, 3)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) +>PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 150, 3)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) value?: T; ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 104, 20)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 154, 20)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) get?(): T; ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 105, 14)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 155, 14)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) set?(value: T): void; ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 106, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 107, 9)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 104, 14)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 156, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 157, 9)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) } type PropDescMap = { ->PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 108, 1)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 110, 17)) +>PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 158, 1)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 160, 17)) [K in keyof T]: PropDesc; ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 111, 5)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 110, 17)) ->PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 100, 3)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 110, 17)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 111, 5)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 161, 5)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 160, 17)) +>PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 150, 3)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 160, 17)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 161, 5)) } declare function defineProp(obj: T, name: K, desc: PropDesc & ThisType): T & Record; ->defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 112, 1)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 114, 30)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 114, 48)) ->obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 114, 52)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) ->name : Symbol(name, Decl(thisTypeInObjectLiterals2.ts, 114, 59)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 114, 30)) ->desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 114, 68)) ->PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 100, 3)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 114, 48)) +>defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 162, 1)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 164, 28)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 164, 30)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 164, 48)) +>obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 164, 52)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 164, 28)) +>name : Symbol(name, Decl(thisTypeInObjectLiterals2.ts, 164, 59)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 164, 30)) +>desc : Symbol(desc, Decl(thisTypeInObjectLiterals2.ts, 164, 68)) +>PropDesc : Symbol(PropDesc, Decl(thisTypeInObjectLiterals2.ts, 150, 3)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 164, 48)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 114, 28)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 164, 28)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 164, 28)) >Record : Symbol(Record, Decl(lib.d.ts, --, --)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 114, 30)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 114, 48)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 164, 30)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 164, 48)) declare function defineProps(obj: T, descs: PropDescMap & ThisType): T & U; ->defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 114, 120)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 116, 31)) ->obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 116, 35)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) ->descs : Symbol(descs, Decl(thisTypeInObjectLiterals2.ts, 116, 42)) ->PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 108, 1)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 116, 31)) +>defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 164, 120)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 166, 29)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 166, 31)) +>obj : Symbol(obj, Decl(thisTypeInObjectLiterals2.ts, 166, 35)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 166, 29)) +>descs : Symbol(descs, Decl(thisTypeInObjectLiterals2.ts, 166, 42)) +>PropDescMap : Symbol(PropDescMap, Decl(thisTypeInObjectLiterals2.ts, 158, 1)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 166, 31)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 116, 29)) ->U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 116, 31)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 166, 29)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 166, 29)) +>U : Symbol(U, Decl(thisTypeInObjectLiterals2.ts, 166, 31)) let p10 = defineProp(p1, "foo", { value: 42 }); ->p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 118, 3)) ->defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 112, 1)) +>p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 168, 3)) +>defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 162, 1)) >p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 118, 33)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 168, 33)) p10.foo = p10.foo + 1; >p10.foo : Symbol(foo) ->p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 118, 3)) +>p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 168, 3)) >foo : Symbol(foo) >p10.foo : Symbol(foo) ->p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 118, 3)) +>p10 : Symbol(p10, Decl(thisTypeInObjectLiterals2.ts, 168, 3)) >foo : Symbol(foo) let p11 = defineProp(p1, "bar", { ->p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 121, 3)) ->defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 112, 1)) +>p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 171, 3)) +>defineProp : Symbol(defineProp, Decl(thisTypeInObjectLiterals2.ts, 162, 1)) >p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) get() { ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 121, 33)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 171, 33)) return this.x; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) @@ -391,41 +567,41 @@ let p11 = defineProp(p1, "bar", { }, set(value: number) { ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 124, 6)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 125, 8)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 174, 6)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 175, 8)) this.x = value; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 125, 8)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 175, 8)) } }); p11.bar = p11.bar + 1; >p11.bar : Symbol(bar) ->p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 121, 3)) +>p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 171, 3)) >bar : Symbol(bar) >p11.bar : Symbol(bar) ->p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 121, 3)) +>p11 : Symbol(p11, Decl(thisTypeInObjectLiterals2.ts, 171, 3)) >bar : Symbol(bar) let p12 = defineProps(p1, { ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 114, 120)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>defineProps : Symbol(defineProps, Decl(thisTypeInObjectLiterals2.ts, 164, 120)) >p1 : Symbol(p1, Decl(thisTypeInObjectLiterals2.ts, 36, 3)) foo: { ->foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) +>foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) value: 42 ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 132, 10)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 182, 10)) }, bar: { ->bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) +>bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) get(): number { ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 135, 10)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 185, 10)) return this.x; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) @@ -434,173 +610,173 @@ let p12 = defineProps(p1, { }, set(value: number) { ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 138, 10)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 139, 12)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 188, 10)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 189, 12)) this.x = value; >this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) >this : Symbol(__type, Decl(thisTypeInObjectLiterals2.ts, 29, 12)) >x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 29, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 139, 12)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 189, 12)) } } }); p12.foo = p12.foo + 1; ->p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) ->p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 131, 27)) +>p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) +>p12.foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>foo : Symbol(foo, Decl(thisTypeInObjectLiterals2.ts, 181, 27)) p12.bar = p12.bar + 1; ->p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) ->p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) ->p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 131, 3)) ->bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 134, 6)) +>p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) +>p12.bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) +>p12 : Symbol(p12, Decl(thisTypeInObjectLiterals2.ts, 181, 3)) +>bar : Symbol(bar, Decl(thisTypeInObjectLiterals2.ts, 184, 6)) // Proof of concept for typing of Vue.js type Accessors = { [K in keyof T]: (() => T[K]) | Computed }; ->Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 145, 22)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 149, 23)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 149, 23)) ->Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 151, 39)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 149, 15)) ->K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 149, 23)) +>Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 195, 22)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 199, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 199, 23)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 199, 15)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 199, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 199, 23)) +>Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 201, 39)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 199, 15)) +>K : Symbol(K, Decl(thisTypeInObjectLiterals2.ts, 199, 23)) type Dictionary = { [x: string]: T } ->Dictionary : Symbol(Dictionary, Decl(thisTypeInObjectLiterals2.ts, 149, 70)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 151, 16)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 151, 24)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 151, 16)) +>Dictionary : Symbol(Dictionary, Decl(thisTypeInObjectLiterals2.ts, 199, 70)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 201, 16)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 201, 24)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 201, 16)) type Computed = { ->Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 151, 39)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 153, 14)) +>Computed : Symbol(Computed, Decl(thisTypeInObjectLiterals2.ts, 201, 39)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 203, 14)) get?(): T; ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 153, 20)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 153, 14)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 203, 20)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 203, 14)) set?(value: T): void; ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 154, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 155, 9)) ->T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 153, 14)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 204, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 205, 9)) +>T : Symbol(T, Decl(thisTypeInObjectLiterals2.ts, 203, 14)) } type VueOptions = ThisType & { ->VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 156, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 158, 18)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 158, 21)) +>VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 206, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 208, 16)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 208, 18)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 208, 21)) >ThisType : Symbol(ThisType, Decl(lib.d.ts, --, --)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 158, 18)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 158, 21)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 208, 16)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 208, 18)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 208, 21)) data?: D | (() => D); ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 158, 50)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 158, 16)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 208, 50)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 208, 16)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 208, 16)) methods?: M; ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 159, 25)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 158, 18)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 209, 25)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 208, 18)) computed?: Accessors

; ->computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 160, 16)) ->Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 145, 22)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 158, 21)) +>computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 210, 16)) +>Accessors : Symbol(Accessors, Decl(thisTypeInObjectLiterals2.ts, 195, 22)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 208, 21)) } declare const Vue: new (options: VueOptions) => D & M & P; ->Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 164, 13)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 164, 24)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 164, 26)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 164, 29)) ->options : Symbol(options, Decl(thisTypeInObjectLiterals2.ts, 164, 33)) ->VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 156, 1)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 164, 24)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 164, 26)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 164, 29)) ->D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 164, 24)) ->M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 164, 26)) ->P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 164, 29)) +>Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 214, 13)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 214, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 214, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 214, 29)) +>options : Symbol(options, Decl(thisTypeInObjectLiterals2.ts, 214, 33)) +>VueOptions : Symbol(VueOptions, Decl(thisTypeInObjectLiterals2.ts, 206, 1)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 214, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 214, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 214, 29)) +>D : Symbol(D, Decl(thisTypeInObjectLiterals2.ts, 214, 24)) +>M : Symbol(M, Decl(thisTypeInObjectLiterals2.ts, 214, 26)) +>P : Symbol(P, Decl(thisTypeInObjectLiterals2.ts, 214, 29)) let vue = new Vue({ ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 164, 13)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>Vue : Symbol(Vue, Decl(thisTypeInObjectLiterals2.ts, 214, 13)) data: () => ({ x: 1, y: 2 }), ->data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 166, 19)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) ->y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 167, 24)) +>data : Symbol(data, Decl(thisTypeInObjectLiterals2.ts, 216, 19)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) +>y : Symbol(y, Decl(thisTypeInObjectLiterals2.ts, 217, 24)) methods: { ->methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 167, 33)) +>methods : Symbol(methods, Decl(thisTypeInObjectLiterals2.ts, 217, 33)) f(x: string) { ->f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 168, 14)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 169, 10)) +>f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 218, 14)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 219, 10)) return this.x; ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) } }, computed: { ->computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 172, 6)) +>computed : Symbol(computed, Decl(thisTypeInObjectLiterals2.ts, 222, 6)) test(): number { ->test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 173, 15)) +>test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 223, 15)) return this.x; ->this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>this.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) }, hello: { ->hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 176, 10)) +>hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 226, 10)) get() { ->get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 177, 16)) +>get : Symbol(get, Decl(thisTypeInObjectLiterals2.ts, 227, 16)) return "hi"; }, set(value: string) { ->set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 180, 14)) ->value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 181, 16)) +>set : Symbol(set, Decl(thisTypeInObjectLiterals2.ts, 230, 14)) +>value : Symbol(value, Decl(thisTypeInObjectLiterals2.ts, 231, 16)) } } } }); vue; ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) vue.x; ->vue.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 167, 18)) +>vue.x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>x : Symbol(x, Decl(thisTypeInObjectLiterals2.ts, 217, 18)) vue.f("abc"); ->vue.f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 168, 14)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 168, 14)) +>vue.f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 218, 14)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>f : Symbol(f, Decl(thisTypeInObjectLiterals2.ts, 218, 14)) vue.test; ->vue.test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 173, 15)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 173, 15)) +>vue.test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 223, 15)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>test : Symbol(test, Decl(thisTypeInObjectLiterals2.ts, 223, 15)) vue.hello; ->vue.hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 176, 10)) ->vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 166, 3)) ->hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 176, 10)) +>vue.hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 226, 10)) +>vue : Symbol(vue, Decl(thisTypeInObjectLiterals2.ts, 216, 3)) +>hello : Symbol(hello, Decl(thisTypeInObjectLiterals2.ts, 226, 10)) diff --git a/tests/baselines/reference/thisTypeInObjectLiterals2.types b/tests/baselines/reference/thisTypeInObjectLiterals2.types index cc41be6b8c6..2742ad2c408 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals2.types +++ b/tests/baselines/reference/thisTypeInObjectLiterals2.types @@ -141,6 +141,158 @@ let p1: Point = { } }; +let p2: Point | null = { +>p2 : Point | null +>Point : Point +>null : null +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void +>dx : number +>dy : number +>dz : number | undefined + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } + } +}; + +let p3: Point | undefined = { +>p3 : Point | undefined +>Point : Point +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void +>dx : number +>dy : number +>dz : number | undefined + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } + } +}; + +let p4: Point | null | undefined = { +>p4 : Point | null | undefined +>Point : Point +>null : null +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void +>dx : number +>dy : number +>dz : number | undefined + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } + } +}; + declare function f1(p: Point): void; >f1 : (p: Point) => void >p : Point @@ -196,6 +348,62 @@ f1({ } }); +declare function f2(p: Point | null | undefined): void; +>f2 : (p: Point | null | undefined) => void +>p : Point | null | undefined +>Point : Point +>null : null + +f2({ +>f2({ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }}) : void +>f2 : (p: Point | null | undefined) => void +>{ x: 10, y: 20, moveBy(dx, dy, dz) { this.x += dx; this.y += dy; if (this.z && dz) { this.z += dz; } }} : { x: number; y: number; moveBy(dx: number, dy: number, dz: number | undefined): void; } + + x: 10, +>x : number +>10 : 10 + + y: 20, +>y : number +>20 : 20 + + moveBy(dx, dy, dz) { +>moveBy : (dx: number, dy: number, dz: number | undefined) => void +>dx : number +>dy : number +>dz : number | undefined + + this.x += dx; +>this.x += dx : number +>this.x : number +>this : Point +>x : number +>dx : number + + this.y += dy; +>this.y += dy : number +>this.y : number +>this : Point +>y : number +>dy : number + + if (this.z && dz) { +>this.z && dz : number | undefined +>this.z : number | undefined +>this : Point +>z : number | undefined +>dz : number | undefined + + this.z += dz; +>this.z += dz : number +>this.z : number +>this : Point +>z : number +>dz : number + } + } +}); + // In methods of an object literal with a contextual type that includes some // ThisType, 'this' is of type T. From 36513f21aba6b77ab1147320c82ac218c3c3df97 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 7 Mar 2017 09:14:51 -0800 Subject: [PATCH 112/167] Remove only undefined, not null | undefined, from declared type --- src/compiler/checker.ts | 2 +- .../defaultParameterAddsUndefinedWithStrictNullChecks.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f17f079008b..8ba023ce05a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10929,7 +10929,7 @@ namespace ts { declaration.initializer && getFalsyFlags(declaredType) & TypeFlags.Undefined && !(getFalsyFlags(checkExpression(declaration.initializer)) & TypeFlags.Undefined); - return annotationIncludesUndefined ? getNonNullableType(declaredType) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, TypeFacts.NEUndefined) : declaredType; } function checkIdentifier(node: Identifier): Type { diff --git a/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts b/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts index 04a9e668b32..d2e167c83a3 100644 --- a/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts +++ b/tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts @@ -27,6 +27,13 @@ function foo4(x: string | undefined = undefined, b: number) { x = undefined; } +type OptionalNullableString = string | null | undefined; +function allowsNull(val: OptionalNullableString = "") { + val = null; + val = 'string and null are both ok'; +} +allowsNull(null); // still allows passing null + // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 From 2325fda8a65b140e7b9b3c4b4e1e2f7dd7872629 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 7 Mar 2017 09:28:51 -0800 Subject: [PATCH 113/167] Move isFlowNarrowable call inside getFlowTypeOfReference --- src/compiler/checker.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8ba023ce05a..fbd3ac458f0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10242,8 +10242,11 @@ namespace ts { return reference.flowNode && (type.flags & TypeFlags.Narrowable || couldBeUninitialized); } - function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node) { + function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; + if (!isFlowNarrowable(reference, declaredType, couldBeUninitialized)) { + return declaredType; + } const visitedFlowStart = visitedFlowCount; const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -11053,7 +11056,7 @@ namespace ts { const initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, getRootDeclaration(declaration) as VariableLikeDeclaration) : type) : type === autoType || type === autoArrayType ? undefinedType : includeFalsyTypes(type, TypeFlags.Undefined); - const flowType = isFlowNarrowable(node, type, !assumeInitialized) ? getFlowTypeOfReference(node, type, initialType, flowContainer) : type; + const flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. @@ -11319,7 +11322,7 @@ namespace ts { if (isClassLike(container.parent)) { const symbol = getSymbolOfNode(container.parent); const type = hasModifier(container, ModifierFlags.Static) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; - return isFlowNarrowable(node, type) ? getFlowTypeOfReference(node, type) : type; + return getFlowTypeOfReference(node, type); } if (isInJavaScriptFile(node)) { @@ -13310,7 +13313,7 @@ namespace ts { !(prop.flags & SymbolFlags.Method && propType.flags & TypeFlags.Union)) { return propType; } - const flowType = isFlowNarrowable(node, propType) ? getFlowTypeOfReference(node, propType) : propType; + const flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } From c1f4c9c54360cad8ecffa8ab5524168ec7a55ab7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 7 Mar 2017 09:29:29 -0800 Subject: [PATCH 114/167] Update baselines --- ...ameterAddsUndefinedWithStrictNullChecks.js | 15 +++++++ ...rAddsUndefinedWithStrictNullChecks.symbols | 39 +++++++++++++------ ...terAddsUndefinedWithStrictNullChecks.types | 25 ++++++++++++ 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js index 7f9cf553fe4..0477481c95c 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js @@ -26,6 +26,13 @@ function foo4(x: string | undefined = undefined, b: number) { x = undefined; } +type OptionalNullableString = string | null | undefined; +function allowsNull(val: OptionalNullableString = "") { + val = null; + val = 'string and null are both ok'; +} +allowsNull(null); // still allows passing null + // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 @@ -81,6 +88,12 @@ function foo4(x, b) { x; // should be string | undefined x = undefined; } +function allowsNull(val) { + if (val === void 0) { val = ""; } + val = null; + val = 'string and null are both ok'; +} +allowsNull(null); // still allows passing null // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 foo1(undefined, 1); foo2(undefined, 1); @@ -111,6 +124,8 @@ declare function foo1(x: string | undefined, b: number): void; declare function foo2(x: string | undefined, b: number): void; declare function foo3(x: string | undefined, b: number): void; declare function foo4(x: string | undefined, b: number): void; +declare type OptionalNullableString = string | null | undefined; +declare function allowsNull(val?: OptionalNullableString): void; declare function removeUndefinedButNotFalse(x?: boolean): false | undefined; declare const cond: boolean; declare function removeNothing(y?: boolean | undefined): boolean; diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols index a484377f3f4..80abc32ee73 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols @@ -86,6 +86,23 @@ function foo4(x: string | undefined = undefined, b: number) { >undefined : Symbol(undefined) } +type OptionalNullableString = string | null | undefined; +>OptionalNullableString : Symbol(OptionalNullableString, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 25, 1)) + +function allowsNull(val: OptionalNullableString = "") { +>allowsNull : Symbol(allowsNull, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 27, 56)) +>val : Symbol(val, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 28, 20)) +>OptionalNullableString : Symbol(OptionalNullableString, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 25, 1)) + + val = null; +>val : Symbol(val, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 28, 20)) + + val = 'string and null are both ok'; +>val : Symbol(val, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 28, 20)) +} +allowsNull(null); // still allows passing null +>allowsNull : Symbol(allowsNull, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 27, 56)) + // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 @@ -107,35 +124,35 @@ foo4(undefined, 1); function removeUndefinedButNotFalse(x = true) { ->removeUndefinedButNotFalse : Symbol(removeUndefinedButNotFalse, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 33, 19)) ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 36, 36)) +>removeUndefinedButNotFalse : Symbol(removeUndefinedButNotFalse, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 19)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 36)) if (x === false) { ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 36, 36)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 36)) return x; ->x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 36, 36)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 36)) } } declare const cond: boolean; ->cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 42, 13)) +>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 49, 13)) function removeNothing(y = cond ? true : undefined) { ->removeNothing : Symbol(removeNothing, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 42, 28)) ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23)) ->cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 42, 13)) +>removeNothing : Symbol(removeNothing, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 49, 28)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23)) +>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 49, 13)) >undefined : Symbol(undefined) if (y !== undefined) { ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23)) >undefined : Symbol(undefined) if (y === false) { ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23)) return y; ->y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 43, 23)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 50, 23)) } } return true; diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types index 54b9cdf2a9b..8b8aea6370f 100644 --- a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types @@ -116,6 +116,31 @@ function foo4(x: string | undefined = undefined, b: number) { >undefined : undefined } +type OptionalNullableString = string | null | undefined; +>OptionalNullableString : OptionalNullableString +>null : null + +function allowsNull(val: OptionalNullableString = "") { +>allowsNull : (val?: OptionalNullableString) => void +>val : OptionalNullableString +>OptionalNullableString : OptionalNullableString +>"" : "" + + val = null; +>val = null : null +>val : OptionalNullableString +>null : null + + val = 'string and null are both ok'; +>val = 'string and null are both ok' : "string and null are both ok" +>val : OptionalNullableString +>'string and null are both ok' : "string and null are both ok" +} +allowsNull(null); // still allows passing null +>allowsNull(null) : void +>allowsNull : (val?: OptionalNullableString) => void +>null : null + // .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 From 0c53b539c8197c166e1357f64dc315fed2d1529a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 7 Mar 2017 09:52:45 -0800 Subject: [PATCH 115/167] Fix more gulp.dests to use the relative path of the tsconfig --- Gulpfile.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 3d4bae39a32..ac6102353c0 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -416,7 +416,7 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => { file.path = nodeDefinitionsFile; return content + "\r\nexport = ts;"; })) - .pipe(gulp.dest(".")), + .pipe(gulp.dest("src/services")), completedDts.pipe(clone()) .pipe(insert.transform((content, file) => { file.path = nodeStandaloneDefinitionsFile; @@ -477,12 +477,12 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { return merge2([ js.pipe(prependCopyright()) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")), + .pipe(gulp.dest("src/server")), dts.pipe(prependCopyright(/*outputCopyright*/true)) .pipe(insert.transform((content) => { return content + "\r\nexport = ts;\r\nexport as namespace ts;"; })) - .pipe(gulp.dest(".")) + .pipe(gulp.dest("src/server")) ]); }); From 24c8de21c471c2a866a5dff7ce006343bebae52e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 7 Mar 2017 10:20:02 -0800 Subject: [PATCH 116/167] Inline isFlowNarrowable --- src/compiler/checker.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fbd3ac458f0..932b2e9c331 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10238,13 +10238,9 @@ namespace ts { return false; } - function isFlowNarrowable(reference: Node, type: Type, couldBeUninitialized?: boolean) { - return reference.flowNode && (type.flags & TypeFlags.Narrowable || couldBeUninitialized); - } - function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; - if (!isFlowNarrowable(reference, declaredType, couldBeUninitialized)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; } const visitedFlowStart = visitedFlowCount; From 7f85c228e869c4e32c82b4bffda7c8eca3bb4f3b Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 7 Mar 2017 11:47:26 -0800 Subject: [PATCH 117/167] Fix tslint compilation in gulp --- Gulpfile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index ac6102353c0..e025ce6eaa8 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -960,7 +960,7 @@ gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", s }); gulp.task("build-rules", "Compiles tslint rules to js", () => { - const settings: tsc.Settings = getCompilerSettings({ module: "commonjs" }, /*useBuiltCompiler*/ false); + const settings: tsc.Settings = getCompilerSettings({ module: "commonjs", "lib": ["es6"] }, /*useBuiltCompiler*/ false); const dest = path.join(builtLocalDirectory, "tslint"); return gulp.src("scripts/tslint/**/*.ts") .pipe(newer({ From 3c751ecdad81f181e246477e06e841f27e8ef35b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Mar 2017 11:47:38 -0800 Subject: [PATCH 118/167] Update baseline --- .../reference/moduleExportAlias.types | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/baselines/reference/moduleExportAlias.types b/tests/baselines/reference/moduleExportAlias.types index 2fbc6322955..9fda7560e37 100644 --- a/tests/baselines/reference/moduleExportAlias.types +++ b/tests/baselines/reference/moduleExportAlias.types @@ -224,19 +224,19 @@ multipleDeclarationAlias5.func9 = function () { }; >function () { } : () => void var multipleDeclarationAlias6 = exports = module.exports = {}; ->multipleDeclarationAlias6 : {} ->exports = module.exports = {} : {} +>multipleDeclarationAlias6 : { [x: string]: any; } +>exports = module.exports = {} : { [x: string]: any; } >exports : any ->module.exports = {} : {} +>module.exports = {} : { [x: string]: any; } >module.exports : any >module : any >exports : any ->{} : {} +>{} : { [x: string]: any; } multipleDeclarationAlias6.func10 = function () { }; >multipleDeclarationAlias6.func10 = function () { } : () => void >multipleDeclarationAlias6.func10 : any ->multipleDeclarationAlias6 : {} +>multipleDeclarationAlias6 : { [x: string]: any; } >func10 : any >function () { } : () => void @@ -295,13 +295,13 @@ module.exports.func12 = function () { }; >function () { } : () => void exports = module.exports = {}; ->exports = module.exports = {} : {} +>exports = module.exports = {} : { [x: string]: any; } >exports : any ->module.exports = {} : {} +>module.exports = {} : { [x: string]: any; } >module.exports : any >module : any >exports : any ->{} : {} +>{} : { [x: string]: any; } exports.func13 = function () { }; >exports.func13 = function () { } : () => void @@ -320,13 +320,13 @@ module.exports.func14 = function () { }; >function () { } : () => void exports = module.exports = {}; ->exports = module.exports = {} : {} +>exports = module.exports = {} : { [x: string]: any; } >exports : any ->module.exports = {} : {} +>module.exports = {} : { [x: string]: any; } >module.exports : any >module : any >exports : any ->{} : {} +>{} : { [x: string]: any; } exports.func15 = function () { }; >exports.func15 = function () { } : () => void @@ -370,11 +370,11 @@ module.exports.func18 = function () { }; >function () { } : () => void module.exports = {}; ->module.exports = {} : {} +>module.exports = {} : { [x: string]: any; } >module.exports : any >module : any >exports : any ->{} : {} +>{} : { [x: string]: any; } exports.func19 = function () { }; >exports.func19 = function () { } : () => void From fab4ef0bdeae9d192c3efadeb7ef62fe9028d4cd Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 7 Mar 2017 13:26:41 -0800 Subject: [PATCH 119/167] cache semantic and declaration diagnostics in program (#14516) --- src/compiler/program.ts | 44 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d9ddf486e0d..abb8b0b2f09 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -290,6 +290,11 @@ namespace ts { return resolutions; } + interface DiagnosticCache { + perFile?: FileMap; + allDiagnostics?: Diagnostic[]; + } + export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program { let program: Program; let files: SourceFile[] = []; @@ -298,6 +303,9 @@ namespace ts { let noDiagnosticsTypeChecker: TypeChecker; let classifiableNames: Map; + let cachedSemanticDiagnosticsForFile: DiagnosticCache = {}; + let cachedDeclarationDiagnosticsForFile: DiagnosticCache = {}; + let resolvedTypeReferenceDirectives = createMap(); let fileProcessingDiagnostics = createDiagnosticCollection(); @@ -899,6 +907,10 @@ namespace ts { } function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedSemanticDiagnosticsForFile, getSemanticDiagnosticsForFileNoCache); + } + + function getSemanticDiagnosticsForFileNoCache(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { const typeChecker = getDiagnosticsProducingTypeChecker(); @@ -1094,7 +1106,11 @@ namespace ts { }); } - function getDeclarationDiagnosticsWorker(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getDeclarationDiagnosticsWorker(sourceFile: SourceFile | undefined, cancellationToken: CancellationToken): Diagnostic[] { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache); + } + + function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile| undefined, cancellationToken: CancellationToken) { return runWithCancellationToken(() => { const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. @@ -1102,6 +1118,32 @@ namespace ts { }); } + function getAndCacheDiagnostics( + sourceFile: SourceFile | undefined, + cancellationToken: CancellationToken, + cache: DiagnosticCache, + getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => Diagnostic[]) { + + const cachedResult = sourceFile + ? cache.perFile && cache.perFile.get(sourceFile.path) + : cache.allDiagnostics; + + if (cachedResult) { + return cachedResult; + } + const result = getDiagnostics(sourceFile, cancellationToken) || emptyArray; + if (sourceFile) { + if (!cache.perFile) { + cache.perFile = createFileMap(); + } + cache.perFile.set(sourceFile.path, result); + } + else { + cache.allDiagnostics = result; + } + return result; + } + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } From b7d09ef0152defdf6126b2af1ec2df7e89e63db6 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 8 Mar 2017 12:41:20 -0800 Subject: [PATCH 120/167] Make docComment template indent whitespace-only --- src/harness/fourslash.ts | 9 +++++---- src/services/jsDoc.ts | 3 ++- tests/cases/fourslash/docCommentTemplateIndentation.ts | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 0df9f4f4dd2..35788ebca80 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2248,22 +2248,23 @@ namespace FourSlash { if (expected === undefined) { if (actual) { - this.raiseError(name + " failed - expected no template but got {newText: \"" + actual.newText + "\" caretOffset: " + actual.caretOffset + "}"); + this.raiseError(`${name} failed - expected no template but got {newText: "${actual.newText}", caretOffset: ${actual.caretOffset}}`); } return; } else { if (actual === undefined) { - this.raiseError(name + " failed - expected the template {newText: \"" + actual.newText + "\" caretOffset: " + actual.caretOffset + "} but got nothing instead"); + this.raiseError(`${name} failed - expected the template {newText: "${expected.newText}", caretOffset: "${expected.caretOffset}"} but got nothing instead`); + } if (actual.newText !== expected.newText) { - this.raiseError(name + " failed - expected insertion:\n" + this.clarifyNewlines(expected.newText) + "\nactual insertion:\n" + this.clarifyNewlines(actual.newText)); + this.raiseError(`${name} failed - expected insertion:\n"${this.clarifyNewlines(expected.newText)}"\nactual insertion:\n"${this.clarifyNewlines(actual.newText)}"`); } if (actual.caretOffset !== expected.caretOffset) { - this.raiseError(name + " failed - expected caretOffset: " + expected.caretOffset + ",\nactual caretOffset:" + actual.caretOffset); + this.raiseError(`${name} failed - expected caretOffset: ${expected.caretOffset}\nactual caretOffset:${actual.caretOffset}`); } } } diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index d0cf8c0aec8..d993facbb1d 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -178,7 +178,8 @@ namespace ts.JsDoc { const posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); const lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - const indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // replace non-whitespace characters in prefix with spaces. + const indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, () => " "); const isJavaScriptFile = hasJavaScriptFileExtension(sourceFile.fileName); let docParams = ""; diff --git a/tests/cases/fourslash/docCommentTemplateIndentation.ts b/tests/cases/fourslash/docCommentTemplateIndentation.ts index db7e48dab2e..3f84a73b81f 100644 --- a/tests/cases/fourslash/docCommentTemplateIndentation.ts +++ b/tests/cases/fourslash/docCommentTemplateIndentation.ts @@ -1,13 +1,13 @@ /// // @Filename: indents.ts -/////*0*/ +//// a /*2*/ //// /*1*/ -//// /*2*/function foo() { } +/////*0*/ function foo() { } const noIndentEmptyScaffolding = "/**\r\n * \r\n */"; const oneIndentEmptyScaffolding = "/**\r\n * \r\n */"; -const twoIndentEmptyScaffolding = "/**\r\n * \r\n */\r\n "; +const twoIndentEmptyScaffolding = "/**\r\n * \r\n */"; const noIndentOffset = 8; const oneIndentOffset = noIndentOffset + 4; const twoIndentOffset = oneIndentOffset + 4; @@ -19,4 +19,4 @@ goTo.marker("1"); verify.DocCommentTemplate(oneIndentEmptyScaffolding, oneIndentOffset); goTo.marker("2"); -verify.DocCommentTemplate(twoIndentEmptyScaffolding, twoIndentOffset); \ No newline at end of file +verify.DocCommentTemplate(twoIndentEmptyScaffolding, twoIndentOffset); From 41dbae58f342066d0af8fd0233da9cdb3ead16dd Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Mar 2017 14:15:26 -0800 Subject: [PATCH 121/167] code review comments --- src/compiler/checker.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c161dd3f065..6a4891597b9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9598,7 +9598,7 @@ namespace ts { getInferenceMapper(context))); } else { - inferredType = emptyObjectType; + inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType; } inferenceSucceeded = true; @@ -9614,9 +9614,6 @@ namespace ts { context.inferredTypes[index] = inferredType = instantiatedConstraint; } } - if (context.useAnyForNoInferences && !inferences.length && inferredType === emptyObjectType) { - context.inferredTypes[index] = inferredType = anyType; - } } else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { // If inference failed, it is necessary to record the index of the failed type parameter (the one we are on). From cedad974d21065a748c2597953052108dafa6ee4 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Thu, 5 Jan 2017 11:07:27 +0800 Subject: [PATCH 122/167] fix: add generic info for methods with thisArg of built-in classes when enabling `noImplicitThis`, if assing this argument for methods like `array.forEach` will cause compilation error. This commit fixes it. fix #12548 --- src/lib/es2015.core.d.ts | 20 +- src/lib/es2015.iterable.d.ts | 58 +++++- src/lib/es5.d.ts | 366 ++++++++++++++++++++++++++--------- 3 files changed, 342 insertions(+), 102 deletions(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index eb23ce7901f..88f70758e5a 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -10,7 +10,9 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T | undefined; + find(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): T | undefined; + find(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -21,7 +23,9 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Returns the this object after filling the section identified by start and end with value @@ -52,7 +56,9 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; /** @@ -357,7 +363,9 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; + find(predicate: (this: undefined, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; + find(predicate: (this: undefined, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -368,7 +376,9 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; } interface RegExp { diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 247017bae7d..fe56c6e8bfb 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -54,7 +54,9 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + from(iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): Array; + from(iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): Array; + from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; /** * Creates an array from an iterable object. @@ -180,7 +182,11 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: Iterable): Int8Array; } /** @@ -212,7 +218,11 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: Iterable): Uint8Array; } /** @@ -247,7 +257,11 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: Iterable): Uint8ClampedArray; } /** @@ -281,7 +295,11 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: Iterable): Int16Array; } /** @@ -313,7 +331,11 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: Iterable): Uint16Array; } /** @@ -345,7 +367,11 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: Iterable): Int32Array; } /** @@ -377,7 +403,11 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: Iterable): Uint32Array; } /** @@ -409,7 +439,11 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: Iterable): Float32Array; } /** @@ -441,5 +475,9 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: Iterable): Float64Array; } diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 04743f7d77f..61f8e396471 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1050,37 +1050,49 @@ interface ReadonlyArray { * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + every(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + some(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => void): void; + forEach(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => void, thisArg: Z): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + map(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => U): U[]; + map(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => U, thisArg: Z): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => value is S, thisArg?: any): S[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => value is S): S[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: undefined): S[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: Z): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => any, thisArg?: any): T[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => any): T[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => any, thisArg: Z): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -1197,55 +1209,73 @@ interface Array { * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: T, index: number, array: T[]) => boolean): boolean; + every(callbackfn: (this: undefined, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: T, index: number, array: T[]) => boolean): boolean; + some(callbackfn: (this: undefined, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: T, index: number, array: T[]) => void): void; + forEach(callbackfn: (this: undefined, value: T, index: number, array: T[]) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: T[]) => void, thisArg: Z): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; + map(this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; + map(this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; + map(this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + map(callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; + map(callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: T[]) => any): T[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: T[]) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: T[]) => any, thisArg: Z): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -1590,7 +1620,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1609,7 +1641,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => any): Int8Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => any, thisArg: undefined): Int8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => any, thisArg: Z): Int8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1620,7 +1654,9 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1631,7 +1667,9 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1640,7 +1678,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1678,7 +1718,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => number): Int8Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => number, thisArg: undefined): Int8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => number, thisArg: Z): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1762,7 +1804,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -1814,7 +1858,11 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: ArrayLike): Int8Array; } declare const Int8Array: Int8ArrayConstructor; @@ -1863,7 +1911,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1882,7 +1932,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => any): Uint8Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => any, thisArg: undefined): Uint8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => any, thisArg: Z): Uint8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1893,7 +1945,9 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1904,7 +1958,9 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1913,7 +1969,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1951,7 +2009,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => number): Uint8Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => number, thisArg: undefined): Uint8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => number, thisArg: Z): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2035,7 +2095,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2088,7 +2150,11 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: ArrayLike): Uint8Array; } declare const Uint8Array: Uint8ArrayConstructor; @@ -2137,7 +2203,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2156,7 +2224,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => any): Uint8ClampedArray; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: undefined): Uint8ClampedArray; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: Z): Uint8ClampedArray; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2167,7 +2237,9 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2178,7 +2250,9 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2187,7 +2261,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2225,7 +2301,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => number): Uint8ClampedArray; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: undefined): Uint8ClampedArray; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: Z): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2309,7 +2387,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2362,7 +2442,11 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: ArrayLike): Uint8ClampedArray; } declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; @@ -2410,7 +2494,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2429,7 +2515,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => any): Int16Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => any, thisArg: undefined): Int16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => any, thisArg: Z): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2440,7 +2528,9 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2451,7 +2541,9 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2460,7 +2552,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2498,7 +2592,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => number): Int16Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => number, thisArg: undefined): Int16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => number, thisArg: Z): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2582,7 +2678,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2635,7 +2733,11 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: ArrayLike): Int16Array; } declare const Int16Array: Int16ArrayConstructor; @@ -2684,7 +2786,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2703,7 +2807,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => any): Uint16Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => any, thisArg: undefined): Uint16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => any, thisArg: Z): Uint16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2714,7 +2820,9 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2725,7 +2833,9 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2734,7 +2844,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2772,7 +2884,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => number): Uint16Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => number, thisArg: undefined): Uint16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => number, thisArg: Z): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2856,7 +2970,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2909,7 +3025,11 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: ArrayLike): Uint16Array; } declare const Uint16Array: Uint16ArrayConstructor; @@ -2957,7 +3077,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2976,7 +3098,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => any): Int32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => any, thisArg: undefined): Int32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => any, thisArg: Z): Int32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2987,7 +3111,9 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2998,7 +3124,9 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3007,7 +3135,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3045,7 +3175,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => number): Int32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => number, thisArg: undefined): Int32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => number, thisArg: Z): Int32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3129,7 +3261,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3182,7 +3316,11 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: ArrayLike): Int32Array; } declare const Int32Array: Int32ArrayConstructor; @@ -3230,7 +3368,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3249,7 +3389,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => any): Uint32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => any, thisArg: undefined): Uint32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => any, thisArg: Z): Uint32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3260,7 +3402,9 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3271,7 +3415,9 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3280,7 +3426,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3318,7 +3466,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => number): Uint32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => number, thisArg: undefined): Uint32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => number, thisArg: Z): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3402,7 +3552,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3455,7 +3607,11 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: ArrayLike): Uint32Array; } declare const Uint32Array: Uint32ArrayConstructor; @@ -3503,7 +3659,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3522,7 +3680,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => any): Float32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => any, thisArg: undefined): Float32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => any, thisArg: Z): Float32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3533,7 +3693,9 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3544,7 +3706,9 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3553,7 +3717,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3591,7 +3757,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => number): Float32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => number, thisArg: undefined): Float32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => number, thisArg: Z): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3675,7 +3843,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3728,7 +3898,11 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: ArrayLike): Float32Array; } declare const Float32Array: Float32ArrayConstructor; @@ -3777,7 +3951,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3796,7 +3972,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => any): Float64Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => any, thisArg: undefined): Float64Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => any, thisArg: Z): Float64Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3807,7 +3985,9 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3818,7 +3998,9 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3827,7 +4009,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3865,7 +4049,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => number): Float64Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => number, thisArg: undefined): Float64Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => number, thisArg: Z): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3949,7 +4135,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -4002,7 +4190,11 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: ArrayLike): Float64Array; } declare const Float64Array: Float64ArrayConstructor; From 18154fe11110e44084f1b6b26f3ed1b7d70c55fc Mon Sep 17 00:00:00 2001 From: e-cloud Date: Thu, 5 Jan 2017 11:08:28 +0800 Subject: [PATCH 123/167] test: add tests for this type in native-this-assignable methods --- .../thisTypeInNativeThisAssignableMethods.js | 710 ++++++ ...sTypeInNativeThisAssignableMethods.symbols | 1569 +++++++++++++ ...hisTypeInNativeThisAssignableMethods.types | 1932 +++++++++++++++++ .../thisTypeInNativeThisAssignableMethods.ts | 398 ++++ 4 files changed, 4609 insertions(+) create mode 100644 tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js create mode 100644 tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols create mode 100644 tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types create mode 100644 tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts diff --git a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js new file mode 100644 index 00000000000..d9020c79e29 --- /dev/null +++ b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js @@ -0,0 +1,710 @@ +//// [thisTypeInNativeThisAssignableMethods.ts] + +class A { + options: string[]; + + addOptions(options: string[]) { + if (!this.options) { + this.options = []; + } + options.forEach(function (item) { + this.options.push(item); + }, this); + return this; + } + + testUndefined(options: string[]) { + const undefinedArr: Array = [] + options.forEach(function () { + undefinedArr.push(this); + }); // case1 + options.forEach(function () { + undefinedArr.push(this); + }, undefined); // case2 + options.forEach(function () { + undefinedArr.push(this); + }, null); // case3 + + const arrLike = {} as ArrayLike + Array.from(arrLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined) + + const iterLike = [] as Iterable + Array.from(iterLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined) + } + + test(options: string[]) { + const thisObject = { + options: [] as string[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + + const arrLike = {} as ArrayLike + Array.from(arrLike, function (item) { + return this.options[item].length + }, thisObject) + + const iterLike = [] as Iterable + Array.from(iterLike, function (item) { + return this.options[item].length + }, thisObject) + } + + test1(options: string[]) { + const thisObject = { + options: [] as ReadonlyArray + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test2(options: Int8Array[]) { + const thisObject = { + options: [] as Int8Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test3(options: Uint8Array[]) { + const thisObject = { + options: [] as Uint8Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test4(options: Float32Array[]) { + const thisObject = { + options: [] as Float32Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test5(options: Uint8ClampedArray[]) { + const thisObject = { + options: [] as Uint8ClampedArray[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test6(options: Int16Array[]) { + const thisObject = { + options: [] as Int16Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test7(options: Uint16Array[]) { + const thisObject = { + options: [] as Uint16Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test8(options: Uint32Array[]) { + const thisObject = { + options: [] as Uint32Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test9(options: Float64Array[]) { + const thisObject = { + options: [] as Float64Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } +} + + +//// [thisTypeInNativeThisAssignableMethods.js] +class A { + addOptions(options) { + if (!this.options) { + this.options = []; + } + options.forEach(function (item) { + this.options.push(item); + }, this); + return this; + } + testUndefined(options) { + const undefinedArr = []; + options.forEach(function () { + undefinedArr.push(this); + }); // case1 + options.forEach(function () { + undefinedArr.push(this); + }, undefined); // case2 + options.forEach(function () { + undefinedArr.push(this); + }, null); // case3 + const arrLike = {}; + Array.from(arrLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined); + const iterLike = []; + Array.from(iterLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined); + } + test(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + const arrLike = {}; + Array.from(arrLike, function (item) { + return this.options[item].length; + }, thisObject); + const iterLike = []; + Array.from(iterLike, function (item) { + return this.options[item].length; + }, thisObject); + } + test1(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test2(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test3(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test4(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test5(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test6(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test7(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test8(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test9(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } +} diff --git a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols new file mode 100644 index 00000000000..2ff555baa54 --- /dev/null +++ b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols @@ -0,0 +1,1569 @@ +=== tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts === + +class A { +>A : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) + + options: string[]; +>options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) + + addOptions(options: string[]) { +>addOptions : Symbol(A.addOptions, Decl(thisTypeInNativeThisAssignableMethods.ts, 2, 22)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 4, 15)) + + if (!this.options) { +>this.options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) +>this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) +>options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) + + this.options = []; +>this.options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) +>this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) +>options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) + } + options.forEach(function (item) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 4, 15)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 8, 34)) + + this.options.push(item); +>this.options.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>this.options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 8, 34)) + + }, this); +>this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) + + return this; +>this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) + } + + testUndefined(options: string[]) { +>testUndefined : Symbol(A.testUndefined, Decl(thisTypeInNativeThisAssignableMethods.ts, 12, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 18)) + + const undefinedArr: Array = [] +>undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 15, 13)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) + + options.forEach(function () { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 18)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + undefinedArr.push(this); +>undefinedArr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 15, 13)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) + + }); // case1 + options.forEach(function () { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 18)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + undefinedArr.push(this); +>undefinedArr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 15, 13)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) + + }, undefined); // case2 +>undefined : Symbol(undefined) + + options.forEach(function () { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 18)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + undefinedArr.push(this); +>undefinedArr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 15, 13)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) + + }, null); // case3 + + const arrLike = {} as ArrayLike +>arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 26, 13)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) + + Array.from(arrLike, function (item) { +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 26, 13)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 27, 38)) + + return this === undefined ? 2 : 1; +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>undefined : Symbol(undefined) + + }, undefined) +>undefined : Symbol(undefined) + + const iterLike = [] as Iterable +>iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 31, 13)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) + + Array.from(iterLike, function (item) { +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 31, 13)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 32, 39)) + + return this === undefined ? 2 : 1; +>this : Symbol(this, Decl(lib.es2015.iterable.d.ts, --, --)) +>undefined : Symbol(undefined) + + }, undefined) +>undefined : Symbol(undefined) + } + + test(options: string[]) { +>test : Symbol(A.test, Decl(thisTypeInNativeThisAssignableMethods.ts, 35, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options: [] as string[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 42, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 42, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 42, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 42, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 46, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 46, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 46, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 46, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 50, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 50, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 50, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 50, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 59, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 59, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 59, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 59, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 63, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 63, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 63, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 63, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 67, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 67, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 67, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 67, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + const arrLike = {} as ArrayLike +>arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 71, 13)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) + + Array.from(arrLike, function (item) { +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 71, 13)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 72, 38)) + + return this.options[item].length +>this.options[item].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 72, 38)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + }, thisObject) +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + const iterLike = [] as Iterable +>iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 76, 13)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) + + Array.from(iterLike, function (item) { +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 76, 13)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 77, 39)) + + return this.options[item].length +>this.options[item].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es2015.iterable.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 77, 39)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + }, thisObject) +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + } + + test1(options: string[]) { +>test1 : Symbol(A.test1, Decl(thisTypeInNativeThisAssignableMethods.ts, 80, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options: [] as ReadonlyArray +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 87, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 87, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 87, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 87, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 91, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 91, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 91, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 91, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 95, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 95, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 95, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 95, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 104, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 104, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 104, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 104, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 108, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 108, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 108, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 108, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 112, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 112, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 112, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 112, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + } + + test2(options: Int8Array[]) { +>test2 : Symbol(A.test2, Decl(thisTypeInNativeThisAssignableMethods.ts, 115, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>Int8Array : Symbol(Int8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options: [] as Int8Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>Int8Array : Symbol(Int8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 122, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 122, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 122, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 122, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 126, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 126, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 126, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 126, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 130, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 130, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 130, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 130, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 139, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 139, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 139, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 139, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 143, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 143, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 143, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 143, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 147, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 147, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 147, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 147, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + } + + test3(options: Uint8Array[]) { +>test3 : Symbol(A.test3, Decl(thisTypeInNativeThisAssignableMethods.ts, 150, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options: [] as Uint8Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 157, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 157, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 157, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 157, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 161, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 161, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 161, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 161, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 165, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 165, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 165, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 165, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 174, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 174, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 174, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 174, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 178, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 178, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 178, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 178, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 182, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 182, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 182, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 182, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + } + + test4(options: Float32Array[]) { +>test4 : Symbol(A.test4, Decl(thisTypeInNativeThisAssignableMethods.ts, 185, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>Float32Array : Symbol(Float32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options: [] as Float32Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>Float32Array : Symbol(Float32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 192, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 192, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 192, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 192, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 196, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 196, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 196, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 196, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 200, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 200, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 200, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 200, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 209, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 209, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 209, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 209, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 213, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 213, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 213, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 213, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 217, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 217, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 217, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 217, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + } + + test5(options: Uint8ClampedArray[]) { +>test5 : Symbol(A.test5, Decl(thisTypeInNativeThisAssignableMethods.ts, 220, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options: [] as Uint8ClampedArray[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 227, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 227, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 227, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 227, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 231, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 231, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 231, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 231, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 235, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 235, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 235, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 235, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 244, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 244, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 244, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 244, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 248, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 248, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 248, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 248, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 252, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 252, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 252, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 252, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + } + + test6(options: Int16Array[]) { +>test6 : Symbol(A.test6, Decl(thisTypeInNativeThisAssignableMethods.ts, 255, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>Int16Array : Symbol(Int16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options: [] as Int16Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>Int16Array : Symbol(Int16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 262, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 262, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 262, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 262, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 266, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 266, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 266, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 266, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 270, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 270, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 270, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 270, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 279, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 279, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 279, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 279, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 283, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 283, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 283, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 283, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 287, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 287, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 287, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 287, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + } + + test7(options: Uint16Array[]) { +>test7 : Symbol(A.test7, Decl(thisTypeInNativeThisAssignableMethods.ts, 290, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options: [] as Uint16Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 297, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 297, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 297, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 297, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 301, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 301, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 301, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 301, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 305, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 305, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 305, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 305, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 314, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 314, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 314, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 314, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 318, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 318, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 318, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 318, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 322, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 322, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 322, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 322, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + } + + test8(options: Uint32Array[]) { +>test8 : Symbol(A.test8, Decl(thisTypeInNativeThisAssignableMethods.ts, 325, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options: [] as Uint32Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 332, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 332, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 332, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 332, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 336, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 336, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 336, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 336, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 340, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 340, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 340, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 340, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 349, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 349, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 349, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 349, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 353, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 353, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 353, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 353, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 357, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 357, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 357, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 357, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + } + + test9(options: Float64Array[]) { +>test9 : Symbol(A.test9, Decl(thisTypeInNativeThisAssignableMethods.ts, 360, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>Float64Array : Symbol(Float64Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options: [] as Float64Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>Float64Array : Symbol(Float64Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 367, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 367, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 367, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 367, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 371, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 371, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 371, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 371, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 375, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 375, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 375, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 375, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 384, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 384, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 384, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 384, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 388, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 388, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 388, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 388, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 392, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 392, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 392, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 392, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + } +} + diff --git a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types new file mode 100644 index 00000000000..e64918181ca --- /dev/null +++ b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types @@ -0,0 +1,1932 @@ +=== tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts === + +class A { +>A : A + + options: string[]; +>options : string[] + + addOptions(options: string[]) { +>addOptions : (options: string[]) => this +>options : string[] + + if (!this.options) { +>!this.options : boolean +>this.options : string[] +>this : this +>options : string[] + + this.options = []; +>this.options = [] : undefined[] +>this.options : string[] +>this : this +>options : string[] +>[] : undefined[] + } + options.forEach(function (item) { +>options.forEach(function (item) { this.options.push(item); }, this) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function (item) { this.options.push(item); } : (this: this, item: string) => void +>item : string + + this.options.push(item); +>this.options.push(item) : number +>this.options.push : (...items: string[]) => number +>this.options : string[] +>this : this +>options : string[] +>push : (...items: string[]) => number +>item : string + + }, this); +>this : this + + return this; +>this : this + } + + testUndefined(options: string[]) { +>testUndefined : (options: string[]) => void +>options : string[] + + const undefinedArr: Array = [] +>undefinedArr : undefined[] +>Array : T[] +>[] : undefined[] + + options.forEach(function () { +>options.forEach(function () { undefinedArr.push(this); }) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function () { undefinedArr.push(this); } : (this: undefined) => void + + undefinedArr.push(this); +>undefinedArr.push(this) : number +>undefinedArr.push : (...items: undefined[]) => number +>undefinedArr : undefined[] +>push : (...items: undefined[]) => number +>this : undefined + + }); // case1 + options.forEach(function () { +>options.forEach(function () { undefinedArr.push(this); }, undefined) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function () { undefinedArr.push(this); } : (this: undefined) => void + + undefinedArr.push(this); +>undefinedArr.push(this) : number +>undefinedArr.push : (...items: undefined[]) => number +>undefinedArr : undefined[] +>push : (...items: undefined[]) => number +>this : undefined + + }, undefined); // case2 +>undefined : undefined + + options.forEach(function () { +>options.forEach(function () { undefinedArr.push(this); }, null) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function () { undefinedArr.push(this); } : (this: undefined) => void + + undefinedArr.push(this); +>undefinedArr.push(this) : number +>undefinedArr.push : (...items: undefined[]) => number +>undefinedArr : undefined[] +>push : (...items: undefined[]) => number +>this : undefined + + }, null); // case3 +>null : null + + const arrLike = {} as ArrayLike +>arrLike : ArrayLike +>{} as ArrayLike : ArrayLike +>{} : {} +>ArrayLike : ArrayLike + + Array.from(arrLike, function (item) { +>Array.from(arrLike, function (item) { return this === undefined ? 2 : 1; }, undefined) : (2 | 1)[] +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>arrLike : ArrayLike +>function (item) { return this === undefined ? 2 : 1; } : (this: undefined, item: number) => 2 | 1 +>item : number + + return this === undefined ? 2 : 1; +>this === undefined ? 2 : 1 : 2 | 1 +>this === undefined : boolean +>this : undefined +>undefined : undefined +>2 : 2 +>1 : 1 + + }, undefined) +>undefined : undefined + + const iterLike = [] as Iterable +>iterLike : Iterable +>[] as Iterable : Iterable +>[] : undefined[] +>Iterable : Iterable + + Array.from(iterLike, function (item) { +>Array.from(iterLike, function (item) { return this === undefined ? 2 : 1; }, undefined) : (2 | 1)[] +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>iterLike : Iterable +>function (item) { return this === undefined ? 2 : 1; } : (this: undefined, item: number) => 2 | 1 +>item : number + + return this === undefined ? 2 : 1; +>this === undefined ? 2 : 1 : 2 | 1 +>this === undefined : boolean +>this : undefined +>undefined : undefined +>2 : 2 +>1 : 1 + + }, undefined) +>undefined : undefined + } + + test(options: string[]) { +>test : (options: string[]) => void +>options : string[] + + const thisObject = { +>thisObject : { options: string[]; } +>{ options: [] as string[] } : { options: string[]; } + + options: [] as string[] +>options : string[] +>[] as string[] : string[] +>[] : undefined[] + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : string +>options.find : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } +>options : string[] +>find : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } +>options : string[] +>findIndex : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : string[] +>options.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>options : string[] +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => string +>val : string +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + return this.options[index]; +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>options : string[] +>some : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : string[] +>options.filter : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any): string[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any, thisArg: undefined): string[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => any, thisArg: Z): string[]; } +>options : string[] +>filter : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any): string[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any, thisArg: undefined): string[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => any, thisArg: Z): string[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>options : string[] +>every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + const arrLike = {} as ArrayLike +>arrLike : ArrayLike +>{} as ArrayLike : ArrayLike +>{} : {} +>ArrayLike : ArrayLike + + Array.from(arrLike, function (item) { +>Array.from(arrLike, function (item) { return this.options[item].length }, thisObject) : number[] +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>arrLike : ArrayLike +>function (item) { return this.options[item].length } : (this: { options: string[]; }, item: number) => number +>item : number + + return this.options[item].length +>this.options[item].length : number +>this.options[item] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>item : number +>length : number + + }, thisObject) +>thisObject : { options: string[]; } + + const iterLike = [] as Iterable +>iterLike : Iterable +>[] as Iterable : Iterable +>[] : undefined[] +>Iterable : Iterable + + Array.from(iterLike, function (item) { +>Array.from(iterLike, function (item) { return this.options[item].length }, thisObject) : number[] +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>iterLike : Iterable +>function (item) { return this.options[item].length } : (this: { options: string[]; }, item: number) => number +>item : number + + return this.options[item].length +>this.options[item].length : number +>this.options[item] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>item : number +>length : number + + }, thisObject) +>thisObject : { options: string[]; } + } + + test1(options: string[]) { +>test1 : (options: string[]) => void +>options : string[] + + const thisObject = { +>thisObject : { options: ReadonlyArray; } +>{ options: [] as ReadonlyArray } : { options: ReadonlyArray; } + + options: [] as ReadonlyArray +>options : ReadonlyArray +>[] as ReadonlyArray : ReadonlyArray +>[] : undefined[] +>ReadonlyArray : ReadonlyArray + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : string +>options.find : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } +>options : string[] +>find : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } +>options : string[] +>findIndex : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : string[] +>options.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>options : string[] +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => string +>val : string +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + return this.options[index]; +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>options : string[] +>some : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : string[] +>options.filter : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any): string[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any, thisArg: undefined): string[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => any, thisArg: Z): string[]; } +>options : string[] +>filter : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any): string[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any, thisArg: undefined): string[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => any, thisArg: Z): string[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>options : string[] +>every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + } + + test2(options: Int8Array[]) { +>test2 : (options: Int8Array[]) => void +>options : Int8Array[] +>Int8Array : Int8Array + + const thisObject = { +>thisObject : { options: Int8Array[]; } +>{ options: [] as Int8Array[] } : { options: Int8Array[]; } + + options: [] as Int8Array[] +>options : Int8Array[] +>[] as Int8Array[] : Int8Array[] +>[] : undefined[] +>Int8Array : Int8Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Int8Array +>options.find : { (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean): Int8Array; (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): Int8Array; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): Int8Array; } +>options : Int8Array[] +>find : { (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean): Int8Array; (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): Int8Array; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): Int8Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean): number; (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): number; } +>options : Int8Array[] +>findIndex : { (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean): number; (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => void): void; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => void, thisArg: Z): void; } +>options : Int8Array[] +>forEach : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => void): void; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Int8Array[] +>options.map : { (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): U[]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): U[]; } +>options : Int8Array[] +>map : { (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): U[]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => Int8Array +>val : Int8Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + return this.options[index]; +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: Z): boolean; } +>options : Int8Array[] +>some : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Int8Array[] +>options.filter : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => any): Int8Array[]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => any, thisArg: undefined): Int8Array[]; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => any, thisArg: Z): Int8Array[]; } +>options : Int8Array[] +>filter : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => any): Int8Array[]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => any, thisArg: undefined): Int8Array[]; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => any, thisArg: Z): Int8Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: Z): boolean; } +>options : Int8Array[] +>every : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + } + + test3(options: Uint8Array[]) { +>test3 : (options: Uint8Array[]) => void +>options : Uint8Array[] +>Uint8Array : Uint8Array + + const thisObject = { +>thisObject : { options: Uint8Array[]; } +>{ options: [] as Uint8Array[] } : { options: Uint8Array[]; } + + options: [] as Uint8Array[] +>options : Uint8Array[] +>[] as Uint8Array[] : Uint8Array[] +>[] : undefined[] +>Uint8Array : Uint8Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8Array +>options.find : { (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): Uint8Array; (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): Uint8Array; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): Uint8Array; } +>options : Uint8Array[] +>find : { (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): Uint8Array; (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): Uint8Array; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): Uint8Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): number; (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): number; } +>options : Uint8Array[] +>findIndex : { (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): number; (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => void): void; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg: Z): void; } +>options : Uint8Array[] +>forEach : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => void): void; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Uint8Array[] +>options.map : { (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): U[]; } +>options : Uint8Array[] +>map : { (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => Uint8Array +>val : Uint8Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + return this.options[index]; +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint8Array[] +>some : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8Array[] +>options.filter : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => any): Uint8Array[]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg: undefined): Uint8Array[]; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg: Z): Uint8Array[]; } +>options : Uint8Array[] +>filter : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => any): Uint8Array[]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg: undefined): Uint8Array[]; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg: Z): Uint8Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint8Array[] +>every : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + } + + test4(options: Float32Array[]) { +>test4 : (options: Float32Array[]) => void +>options : Float32Array[] +>Float32Array : Float32Array + + const thisObject = { +>thisObject : { options: Float32Array[]; } +>{ options: [] as Float32Array[] } : { options: Float32Array[]; } + + options: [] as Float32Array[] +>options : Float32Array[] +>[] as Float32Array[] : Float32Array[] +>[] : undefined[] +>Float32Array : Float32Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Float32Array +>options.find : { (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean): Float32Array; (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): Float32Array; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): Float32Array; } +>options : Float32Array[] +>find : { (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean): Float32Array; (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): Float32Array; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): Float32Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean): number; (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): number; } +>options : Float32Array[] +>findIndex : { (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean): number; (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => void): void; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => void, thisArg: Z): void; } +>options : Float32Array[] +>forEach : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => void): void; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Float32Array[] +>options.map : { (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): U[]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): U[]; } +>options : Float32Array[] +>map : { (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): U[]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => Float32Array +>val : Float32Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + return this.options[index]; +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: Z): boolean; } +>options : Float32Array[] +>some : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Float32Array[] +>options.filter : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => any): Float32Array[]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => any, thisArg: undefined): Float32Array[]; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => any, thisArg: Z): Float32Array[]; } +>options : Float32Array[] +>filter : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => any): Float32Array[]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => any, thisArg: undefined): Float32Array[]; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => any, thisArg: Z): Float32Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: Z): boolean; } +>options : Float32Array[] +>every : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + } + + test5(options: Uint8ClampedArray[]) { +>test5 : (options: Uint8ClampedArray[]) => void +>options : Uint8ClampedArray[] +>Uint8ClampedArray : Uint8ClampedArray + + const thisObject = { +>thisObject : { options: Uint8ClampedArray[]; } +>{ options: [] as Uint8ClampedArray[] } : { options: Uint8ClampedArray[]; } + + options: [] as Uint8ClampedArray[] +>options : Uint8ClampedArray[] +>[] as Uint8ClampedArray[] : Uint8ClampedArray[] +>[] : undefined[] +>Uint8ClampedArray : Uint8ClampedArray + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8ClampedArray +>options.find : { (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): Uint8ClampedArray; (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): Uint8ClampedArray; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): Uint8ClampedArray; } +>options : Uint8ClampedArray[] +>find : { (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): Uint8ClampedArray; (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): Uint8ClampedArray; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): Uint8ClampedArray; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): number; (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): number; } +>options : Uint8ClampedArray[] +>findIndex : { (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): number; (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void): void; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg: Z): void; } +>options : Uint8ClampedArray[] +>forEach : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void): void; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Uint8ClampedArray[] +>options.map : { (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): U[]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): U[]; } +>options : Uint8ClampedArray[] +>map : { (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): U[]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => Uint8ClampedArray +>val : Uint8ClampedArray +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + return this.options[index]; +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: Z): boolean; } +>options : Uint8ClampedArray[] +>some : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8ClampedArray[] +>options.filter : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any): Uint8ClampedArray[]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg: undefined): Uint8ClampedArray[]; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg: Z): Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>filter : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any): Uint8ClampedArray[]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg: undefined): Uint8ClampedArray[]; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg: Z): Uint8ClampedArray[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: Z): boolean; } +>options : Uint8ClampedArray[] +>every : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + } + + test6(options: Int16Array[]) { +>test6 : (options: Int16Array[]) => void +>options : Int16Array[] +>Int16Array : Int16Array + + const thisObject = { +>thisObject : { options: Int16Array[]; } +>{ options: [] as Int16Array[] } : { options: Int16Array[]; } + + options: [] as Int16Array[] +>options : Int16Array[] +>[] as Int16Array[] : Int16Array[] +>[] : undefined[] +>Int16Array : Int16Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Int16Array +>options.find : { (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean): Int16Array; (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): Int16Array; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): Int16Array; } +>options : Int16Array[] +>find : { (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean): Int16Array; (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): Int16Array; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): Int16Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean): number; (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): number; } +>options : Int16Array[] +>findIndex : { (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean): number; (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => void): void; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => void, thisArg: Z): void; } +>options : Int16Array[] +>forEach : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => void): void; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Int16Array[] +>options.map : { (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): U[]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): U[]; } +>options : Int16Array[] +>map : { (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): U[]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => Int16Array +>val : Int16Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + return this.options[index]; +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: Z): boolean; } +>options : Int16Array[] +>some : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Int16Array[] +>options.filter : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => any): Int16Array[]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => any, thisArg: undefined): Int16Array[]; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => any, thisArg: Z): Int16Array[]; } +>options : Int16Array[] +>filter : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => any): Int16Array[]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => any, thisArg: undefined): Int16Array[]; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => any, thisArg: Z): Int16Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: Z): boolean; } +>options : Int16Array[] +>every : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + } + + test7(options: Uint16Array[]) { +>test7 : (options: Uint16Array[]) => void +>options : Uint16Array[] +>Uint16Array : Uint16Array + + const thisObject = { +>thisObject : { options: Uint16Array[]; } +>{ options: [] as Uint16Array[] } : { options: Uint16Array[]; } + + options: [] as Uint16Array[] +>options : Uint16Array[] +>[] as Uint16Array[] : Uint16Array[] +>[] : undefined[] +>Uint16Array : Uint16Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint16Array +>options.find : { (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): Uint16Array; (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): Uint16Array; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): Uint16Array; } +>options : Uint16Array[] +>find : { (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): Uint16Array; (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): Uint16Array; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): Uint16Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): number; (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): number; } +>options : Uint16Array[] +>findIndex : { (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): number; (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => void): void; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg: Z): void; } +>options : Uint16Array[] +>forEach : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => void): void; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Uint16Array[] +>options.map : { (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): U[]; } +>options : Uint16Array[] +>map : { (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => Uint16Array +>val : Uint16Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + return this.options[index]; +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint16Array[] +>some : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint16Array[] +>options.filter : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => any): Uint16Array[]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg: undefined): Uint16Array[]; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg: Z): Uint16Array[]; } +>options : Uint16Array[] +>filter : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => any): Uint16Array[]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg: undefined): Uint16Array[]; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg: Z): Uint16Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint16Array[] +>every : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + } + + test8(options: Uint32Array[]) { +>test8 : (options: Uint32Array[]) => void +>options : Uint32Array[] +>Uint32Array : Uint32Array + + const thisObject = { +>thisObject : { options: Uint32Array[]; } +>{ options: [] as Uint32Array[] } : { options: Uint32Array[]; } + + options: [] as Uint32Array[] +>options : Uint32Array[] +>[] as Uint32Array[] : Uint32Array[] +>[] : undefined[] +>Uint32Array : Uint32Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint32Array +>options.find : { (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): Uint32Array; (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): Uint32Array; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): Uint32Array; } +>options : Uint32Array[] +>find : { (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): Uint32Array; (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): Uint32Array; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): Uint32Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): number; (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): number; } +>options : Uint32Array[] +>findIndex : { (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): number; (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => void): void; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg: Z): void; } +>options : Uint32Array[] +>forEach : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => void): void; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Uint32Array[] +>options.map : { (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): U[]; } +>options : Uint32Array[] +>map : { (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => Uint32Array +>val : Uint32Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + return this.options[index]; +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint32Array[] +>some : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint32Array[] +>options.filter : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => any): Uint32Array[]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg: undefined): Uint32Array[]; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg: Z): Uint32Array[]; } +>options : Uint32Array[] +>filter : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => any): Uint32Array[]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg: undefined): Uint32Array[]; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg: Z): Uint32Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint32Array[] +>every : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + } + + test9(options: Float64Array[]) { +>test9 : (options: Float64Array[]) => void +>options : Float64Array[] +>Float64Array : Float64Array + + const thisObject = { +>thisObject : { options: Float64Array[]; } +>{ options: [] as Float64Array[] } : { options: Float64Array[]; } + + options: [] as Float64Array[] +>options : Float64Array[] +>[] as Float64Array[] : Float64Array[] +>[] : undefined[] +>Float64Array : Float64Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Float64Array +>options.find : { (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean): Float64Array; (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): Float64Array; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): Float64Array; } +>options : Float64Array[] +>find : { (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean): Float64Array; (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): Float64Array; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): Float64Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean): number; (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): number; } +>options : Float64Array[] +>findIndex : { (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean): number; (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => void): void; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => void, thisArg: Z): void; } +>options : Float64Array[] +>forEach : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => void): void; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Float64Array[] +>options.map : { (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): U[]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): U[]; } +>options : Float64Array[] +>map : { (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): U[]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => Float64Array +>val : Float64Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + return this.options[index]; +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: Z): boolean; } +>options : Float64Array[] +>some : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Float64Array[] +>options.filter : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => any): Float64Array[]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => any, thisArg: undefined): Float64Array[]; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => any, thisArg: Z): Float64Array[]; } +>options : Float64Array[] +>filter : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => any): Float64Array[]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => any, thisArg: undefined): Float64Array[]; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => any, thisArg: Z): Float64Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: Z): boolean; } +>options : Float64Array[] +>every : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + } +} + diff --git a/tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts b/tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts new file mode 100644 index 00000000000..17ff41c70a7 --- /dev/null +++ b/tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts @@ -0,0 +1,398 @@ +// @target: ES2017 + +class A { + options: string[]; + + addOptions(options: string[]) { + if (!this.options) { + this.options = []; + } + options.forEach(function (item) { + this.options.push(item); + }, this); + return this; + } + + testUndefined(options: string[]) { + const undefinedArr: Array = [] + options.forEach(function () { + undefinedArr.push(this); + }); // case1 + options.forEach(function () { + undefinedArr.push(this); + }, undefined); // case2 + options.forEach(function () { + undefinedArr.push(this); + }, null); // case3 + + const arrLike = {} as ArrayLike + Array.from(arrLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined) + + const iterLike = [] as Iterable + Array.from(iterLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined) + } + + test(options: string[]) { + const thisObject = { + options: [] as string[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + + const arrLike = {} as ArrayLike + Array.from(arrLike, function (item) { + return this.options[item].length + }, thisObject) + + const iterLike = [] as Iterable + Array.from(iterLike, function (item) { + return this.options[item].length + }, thisObject) + } + + test1(options: string[]) { + const thisObject = { + options: [] as ReadonlyArray + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test2(options: Int8Array[]) { + const thisObject = { + options: [] as Int8Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test3(options: Uint8Array[]) { + const thisObject = { + options: [] as Uint8Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test4(options: Float32Array[]) { + const thisObject = { + options: [] as Float32Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test5(options: Uint8ClampedArray[]) { + const thisObject = { + options: [] as Uint8ClampedArray[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test6(options: Int16Array[]) { + const thisObject = { + options: [] as Int16Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test7(options: Uint16Array[]) { + const thisObject = { + options: [] as Uint16Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test8(options: Uint32Array[]) { + const thisObject = { + options: [] as Uint32Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test9(options: Float64Array[]) { + const thisObject = { + options: [] as Float64Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } +} From 5f5aa208162a9182bd770b60cebcfc5c3892e058 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Wed, 11 Jan 2017 09:23:27 +0800 Subject: [PATCH 124/167] test: adjust test case `completionEntryForUnionMethod` --- tests/cases/fourslash/completionEntryForUnionMethod.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cases/fourslash/completionEntryForUnionMethod.ts b/tests/cases/fourslash/completionEntryForUnionMethod.ts index dd0e034cd2d..2dc80e757b2 100644 --- a/tests/cases/fourslash/completionEntryForUnionMethod.ts +++ b/tests/cases/fourslash/completionEntryForUnionMethod.ts @@ -5,7 +5,7 @@ goTo.marker(); verify.quickInfoIs( - "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U];\n (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U];\n (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U];\n (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U];\n (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U];\n (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U];\n (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[];\n}", + "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U];\n (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U];\n (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U];\n (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U];\n (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U];\n (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U];\n (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[];\n (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U];\n (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U];\n (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U];\n (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U];\n (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U];\n (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U];\n (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[];\n (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[];\n}", "Calls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results."); -verify.completionListContains('map', "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U];\n (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U];\n (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U];\n (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U];\n (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U];\n (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U];\n (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[];\n}"); +verify.completionListContains('map', "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U];\n (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U];\n (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U];\n (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U];\n (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U];\n (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U];\n (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[];\n (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U];\n (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U];\n (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U];\n (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U];\n (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U];\n (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U];\n (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[];\n (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[];\n}"); From 81c0bd50ab3851f58bddf493a15cd83bbcd0f828 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Mar 2017 23:03:30 -0800 Subject: [PATCH 125/167] Add --lib es6 to @types/node dependent targets --- Jakefile.js | 10 +++++----- src/harness/tsconfig.json | 4 ++++ src/server/builder.ts | 1 - src/server/cancellationToken/tsconfig.json | 3 +++ src/server/tsconfig.library.json | 3 ++- src/server/typingsInstaller/tsconfig.json | 4 ++++ src/server/watchGuard/tsconfig.json | 10 ++++++++-- 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 971f0be0fde..96f66d6ee5a 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -584,16 +584,16 @@ compileFile( file(typescriptServicesDts, [servicesFile]); var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js"); -compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: true }); +compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: true, lib: "es6" }); var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js"); -compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false }); +compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6,scripthost" }); var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js"); -compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false }); +compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" }); var serverFile = path.join(builtLocalDirectory, "tsserver.js"); -compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true }); +compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6,scripthost" }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); compileFile( @@ -717,7 +717,7 @@ compileFile( /*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources), /*prefixes*/[], /*useBuiltCompiler:*/ true, - /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] }); + /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6,scripthost" }); var internalTests = "internal/"; diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 32af0eb2601..21622325368 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -6,6 +6,10 @@ "declaration": false, "types": [ "node", "mocha", "chai" + ], + "lib": [ + "es6", + "scripthost" ] }, "files": [ diff --git a/src/server/builder.ts b/src/server/builder.ts index a5e7b06e64b..e056f0ae8c7 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -1,7 +1,6 @@ /// /// /// -/// namespace ts.server { diff --git a/src/server/cancellationToken/tsconfig.json b/src/server/cancellationToken/tsconfig.json index fa7f88ca994..604b92b4cf2 100644 --- a/src/server/cancellationToken/tsconfig.json +++ b/src/server/cancellationToken/tsconfig.json @@ -5,6 +5,9 @@ "module": "commonjs", "types": [ "node" + ], + "lib": [ + "es6" ] }, "files": [ diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 76d700dd291..e47600f9f52 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -10,7 +10,8 @@ "target": "es5", "noUnusedLocals": true, "noUnusedParameters": true, - "declaration": true + "declaration": true, + "types": [] }, "files": [ "editorServices.ts", diff --git a/src/server/typingsInstaller/tsconfig.json b/src/server/typingsInstaller/tsconfig.json index 7bfb6c8b1ed..4cfa26f8d9c 100644 --- a/src/server/typingsInstaller/tsconfig.json +++ b/src/server/typingsInstaller/tsconfig.json @@ -5,6 +5,10 @@ "outFile": "../../../built/local/typingsInstaller.js", "types": [ "node" + ], + "lib": [ + "es6", + "scripthost" ] }, "files": [ diff --git a/src/server/watchGuard/tsconfig.json b/src/server/watchGuard/tsconfig.json index ef9b0ab0603..354d3d7f499 100644 --- a/src/server/watchGuard/tsconfig.json +++ b/src/server/watchGuard/tsconfig.json @@ -1,8 +1,14 @@ { - "extends": "../../tsconfig-base", + "extends": "../../tsconfig-base", "compilerOptions": { "removeComments": true, - "outFile": "../../../built/local/watchGuard.js" + "outFile": "../../../built/local/watchGuard.js", + "types": [ + "node" + ], + "lib": [ + "es6" + ] }, "files": [ "watchGuard.ts" From 63cbe8edbff1ae6d60ae3dc60015fc5f59131cb2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Mar 2017 23:10:14 -0800 Subject: [PATCH 126/167] Add es6 to buildProtocol --- Jakefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 96f66d6ee5a..595875dfc32 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -422,7 +422,7 @@ compileFile(buildProtocolJs, [buildProtocolTs], [], /*useBuiltCompiler*/ false, - {noOutFile: true}); + { noOutFile: true, lib: "es6" }); file(buildProtocolDts, [buildProtocolTs, buildProtocolJs, typescriptServicesDts], function() { From 014aeb3fd344df61de22d3ca3002d52040a4500b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 9 Mar 2017 11:50:07 -0800 Subject: [PATCH 127/167] Use immediate constraint instead of base constraint in T[K] relations --- src/compiler/checker.ts | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f36f471ee75..00498191f28 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3973,7 +3973,7 @@ namespace ts { return true; } if (type.flags & TypeFlags.TypeVariable) { - const constraint = getBaseConstraintOfType(type); + const constraint = getBaseConstraintOfType(type); return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; @@ -4989,16 +4989,32 @@ namespace ts { } function getConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { - return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : + type.flags & TypeFlags.IndexedAccess ? getConstraintOfIndexedAccess(type) : + getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type { return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } - function getBaseConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { - const constraint = getResolvedBaseConstraint(type); - return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + function getConstraintOfIndexedAccess(type: IndexedAccessType) { + const baseObjectType = getBaseConstraintOfType(type.objectType); + const baseIndexType = getBaseConstraintOfType(type.indexType); + return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; + } + + function getBaseConstraintOfType(type: Type): Type { + if (type.flags & (TypeFlags.TypeVariable | TypeFlags.UnionOrIntersection)) { + const constraint = getResolvedBaseConstraint(type); + if (constraint !== noConstraintType && constraint !== circularConstraintType) { + return constraint; + } + } + else if (type.flags & TypeFlags.Index) { + return stringType; + } + return undefined; } function hasNonCircularBaseConstraint(type: TypeVariable): boolean { @@ -5096,7 +5112,7 @@ namespace ts { * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type: Type): Type { - const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfType(type) || emptyObjectType : type; + const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfType(type) || emptyObjectType : type; return t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t) : t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : @@ -7921,7 +7937,7 @@ namespace ts { } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - const constraint = getBaseConstraintOfType(target); + const constraint = getBaseConstraintOfType(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -7961,7 +7977,7 @@ namespace ts { else if (source.flags & TypeFlags.IndexedAccess) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - const constraint = getBaseConstraintOfType(source); + const constraint = getConstraintOfType(source); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -9874,7 +9890,7 @@ namespace ts { return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; } if (flags & TypeFlags.TypeVariable) { - return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); + return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } if (flags & TypeFlags.UnionOrIntersection) { return getTypeFactsOfTypes((type).types); @@ -10686,7 +10702,7 @@ namespace ts { return targetType; } if (type.flags & TypeFlags.TypeVariable) { - const constraint = getBaseConstraintOfType(type) || anyType; + const constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); } @@ -16234,7 +16250,7 @@ namespace ts { function isLiteralContextualType(contextualType: Type) { if (contextualType) { if (contextualType.flags & TypeFlags.TypeVariable) { - const constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; + const constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. @@ -17124,7 +17140,7 @@ namespace ts { // Check if we're indexing with a numeric type and the object type is a generic // type with a constraint that has a numeric index signature. if (maybeTypeOfKind(objectType, TypeFlags.TypeVariable) && isTypeOfKind(indexType, TypeFlags.NumberLike)) { - const constraint = getBaseConstraintOfType(objectType); + const constraint = getBaseConstraintOfType(objectType); if (constraint && getIndexInfoOfType(constraint, IndexKind.Number)) { return type; } From 3fb364981b70907ec8d6518c94368f7ed5787545 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 9 Mar 2017 11:50:30 -0800 Subject: [PATCH 128/167] Accept new baselines --- .../mappedTypeRelationships.errors.txt | 64 +++++++++++++------ 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index 22f56dacaf6..bc26bb272f5 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -1,14 +1,18 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(12,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(17,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,5): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,5): error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[keyof U]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,12): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,12): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(31,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. @@ -17,13 +21,19 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(36,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(42,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. - Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[K]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(47,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. - Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[K] | undefined'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T[K]' is not assignable to type 'U[K]'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(52,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(57,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(62,5): error TS2542: Index signature in type 'Readonly' only permits reading. @@ -33,7 +43,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(126,5): error TS2322: Type 'Partial' is not assignable to type 'Identity'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(142,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. Type 'T[P]' is not assignable to type 'U[P]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[P]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(147,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. Type 'keyof U' is not assignable to type 'keyof T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(152,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. @@ -44,7 +55,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(162,5): error TS Type 'keyof T' is not assignable to type 'K'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. Type 'T[P]' is not assignable to type 'U[P]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[P]'. + Type 'T' is not assignable to type 'U'. ==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (27 errors) ==== @@ -62,7 +74,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f4(x: T, y: U, k: K) { @@ -70,7 +83,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f5(x: T, y: U, k: keyof U) { @@ -80,7 +94,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof U]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. } @@ -92,7 +107,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'K' cannot be used to index type 'T'. } @@ -121,8 +137,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f13(x: T, y: Partial, k: K) { @@ -133,8 +152,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f20(x: T, y: Readonly, k: keyof T) { @@ -247,7 +269,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~ !!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[P]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { @@ -288,6 +311,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~ !!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[P]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } \ No newline at end of file From 4b4211f38b40e0042907c74110de3aef4c1508be Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 9 Mar 2017 11:57:56 -0800 Subject: [PATCH 129/167] Add repro --- .../reference/indexedAccessTypeConstraints.js | 86 +++++++++++++ .../indexedAccessTypeConstraints.symbols | 109 ++++++++++++++++ .../indexedAccessTypeConstraints.types | 116 ++++++++++++++++++ .../compiler/indexedAccessTypeConstraints.ts | 36 ++++++ 4 files changed, 347 insertions(+) create mode 100644 tests/baselines/reference/indexedAccessTypeConstraints.js create mode 100644 tests/baselines/reference/indexedAccessTypeConstraints.symbols create mode 100644 tests/baselines/reference/indexedAccessTypeConstraints.types create mode 100644 tests/cases/compiler/indexedAccessTypeConstraints.ts diff --git a/tests/baselines/reference/indexedAccessTypeConstraints.js b/tests/baselines/reference/indexedAccessTypeConstraints.js new file mode 100644 index 00000000000..ec9af906e43 --- /dev/null +++ b/tests/baselines/reference/indexedAccessTypeConstraints.js @@ -0,0 +1,86 @@ +//// [indexedAccessTypeConstraints.ts] + +// Repro from #14557 + +interface IData { + content: T; +} + +type Data = { + get: (prop: K) => T[K]; +}; + +class Parent { + private data: Data; + getData(): Data { + return this.data; + } +} + +export class Foo extends Parent> { + getContent(): C { + return this.getData().get('content'); + } +} + +export class Bar> extends Parent { + getContent(): C { + return this.getData().get('content'); + } +} + +// Repro from #14557 + +function foo(x: C, y: T['content']) { + x = y; +} + + +//// [indexedAccessTypeConstraints.js] +// Repro from #14557 +"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]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var Parent = (function () { + function Parent() { + } + Parent.prototype.getData = function () { + return this.data; + }; + return Parent; +}()); +var Foo = (function (_super) { + __extends(Foo, _super); + function Foo() { + return _super !== null && _super.apply(this, arguments) || this; + } + Foo.prototype.getContent = function () { + return this.getData().get('content'); + }; + return Foo; +}(Parent)); +exports.Foo = Foo; +var Bar = (function (_super) { + __extends(Bar, _super); + function Bar() { + return _super !== null && _super.apply(this, arguments) || this; + } + Bar.prototype.getContent = function () { + return this.getData().get('content'); + }; + return Bar; +}(Parent)); +exports.Bar = Bar; +// Repro from #14557 +function foo(x, y) { + x = y; +} diff --git a/tests/baselines/reference/indexedAccessTypeConstraints.symbols b/tests/baselines/reference/indexedAccessTypeConstraints.symbols new file mode 100644 index 00000000000..b2d10c7ee27 --- /dev/null +++ b/tests/baselines/reference/indexedAccessTypeConstraints.symbols @@ -0,0 +1,109 @@ +=== tests/cases/compiler/indexedAccessTypeConstraints.ts === + +// Repro from #14557 + +interface IData { +>IData : Symbol(IData, Decl(indexedAccessTypeConstraints.ts, 0, 0)) +>T : Symbol(T, Decl(indexedAccessTypeConstraints.ts, 3, 16)) + + content: T; +>content : Symbol(IData.content, Decl(indexedAccessTypeConstraints.ts, 3, 20)) +>T : Symbol(T, Decl(indexedAccessTypeConstraints.ts, 3, 16)) +} + +type Data = { +>Data : Symbol(Data, Decl(indexedAccessTypeConstraints.ts, 5, 1)) +>T : Symbol(T, Decl(indexedAccessTypeConstraints.ts, 7, 10)) + + get: (prop: K) => T[K]; +>get : Symbol(get, Decl(indexedAccessTypeConstraints.ts, 7, 16)) +>K : Symbol(K, Decl(indexedAccessTypeConstraints.ts, 8, 10)) +>T : Symbol(T, Decl(indexedAccessTypeConstraints.ts, 7, 10)) +>prop : Symbol(prop, Decl(indexedAccessTypeConstraints.ts, 8, 29)) +>K : Symbol(K, Decl(indexedAccessTypeConstraints.ts, 8, 10)) +>T : Symbol(T, Decl(indexedAccessTypeConstraints.ts, 7, 10)) +>K : Symbol(K, Decl(indexedAccessTypeConstraints.ts, 8, 10)) + +}; + +class Parent { +>Parent : Symbol(Parent, Decl(indexedAccessTypeConstraints.ts, 9, 2)) +>M : Symbol(M, Decl(indexedAccessTypeConstraints.ts, 11, 13)) + + private data: Data; +>data : Symbol(Parent.data, Decl(indexedAccessTypeConstraints.ts, 11, 17)) +>Data : Symbol(Data, Decl(indexedAccessTypeConstraints.ts, 5, 1)) +>M : Symbol(M, Decl(indexedAccessTypeConstraints.ts, 11, 13)) + + getData(): Data { +>getData : Symbol(Parent.getData, Decl(indexedAccessTypeConstraints.ts, 12, 26)) +>Data : Symbol(Data, Decl(indexedAccessTypeConstraints.ts, 5, 1)) +>M : Symbol(M, Decl(indexedAccessTypeConstraints.ts, 11, 13)) + + return this.data; +>this.data : Symbol(Parent.data, Decl(indexedAccessTypeConstraints.ts, 11, 17)) +>this : Symbol(Parent, Decl(indexedAccessTypeConstraints.ts, 9, 2)) +>data : Symbol(Parent.data, Decl(indexedAccessTypeConstraints.ts, 11, 17)) + } +} + +export class Foo extends Parent> { +>Foo : Symbol(Foo, Decl(indexedAccessTypeConstraints.ts, 16, 1)) +>C : Symbol(C, Decl(indexedAccessTypeConstraints.ts, 18, 17)) +>Parent : Symbol(Parent, Decl(indexedAccessTypeConstraints.ts, 9, 2)) +>IData : Symbol(IData, Decl(indexedAccessTypeConstraints.ts, 0, 0)) +>C : Symbol(C, Decl(indexedAccessTypeConstraints.ts, 18, 17)) + + getContent(): C { +>getContent : Symbol(Foo.getContent, Decl(indexedAccessTypeConstraints.ts, 18, 46)) +>C : Symbol(C, Decl(indexedAccessTypeConstraints.ts, 18, 17)) + + return this.getData().get('content'); +>this.getData().get : Symbol(get, Decl(indexedAccessTypeConstraints.ts, 7, 16)) +>this.getData : Symbol(Parent.getData, Decl(indexedAccessTypeConstraints.ts, 12, 26)) +>this : Symbol(Foo, Decl(indexedAccessTypeConstraints.ts, 16, 1)) +>getData : Symbol(Parent.getData, Decl(indexedAccessTypeConstraints.ts, 12, 26)) +>get : Symbol(get, Decl(indexedAccessTypeConstraints.ts, 7, 16)) + } +} + +export class Bar> extends Parent { +>Bar : Symbol(Bar, Decl(indexedAccessTypeConstraints.ts, 22, 1)) +>C : Symbol(C, Decl(indexedAccessTypeConstraints.ts, 24, 17)) +>T : Symbol(T, Decl(indexedAccessTypeConstraints.ts, 24, 19)) +>IData : Symbol(IData, Decl(indexedAccessTypeConstraints.ts, 0, 0)) +>C : Symbol(C, Decl(indexedAccessTypeConstraints.ts, 24, 17)) +>Parent : Symbol(Parent, Decl(indexedAccessTypeConstraints.ts, 9, 2)) +>T : Symbol(T, Decl(indexedAccessTypeConstraints.ts, 24, 19)) + + getContent(): C { +>getContent : Symbol(Bar.getContent, Decl(indexedAccessTypeConstraints.ts, 24, 59)) +>C : Symbol(C, Decl(indexedAccessTypeConstraints.ts, 24, 17)) + + return this.getData().get('content'); +>this.getData().get : Symbol(get, Decl(indexedAccessTypeConstraints.ts, 7, 16)) +>this.getData : Symbol(Parent.getData, Decl(indexedAccessTypeConstraints.ts, 12, 26)) +>this : Symbol(Bar, Decl(indexedAccessTypeConstraints.ts, 22, 1)) +>getData : Symbol(Parent.getData, Decl(indexedAccessTypeConstraints.ts, 12, 26)) +>get : Symbol(get, Decl(indexedAccessTypeConstraints.ts, 7, 16)) + } +} + +// Repro from #14557 + +function foo(x: C, y: T['content']) { +>foo : Symbol(foo, Decl(indexedAccessTypeConstraints.ts, 28, 1)) +>C : Symbol(C, Decl(indexedAccessTypeConstraints.ts, 32, 13)) +>T : Symbol(T, Decl(indexedAccessTypeConstraints.ts, 32, 15)) +>content : Symbol(content, Decl(indexedAccessTypeConstraints.ts, 32, 27)) +>C : Symbol(C, Decl(indexedAccessTypeConstraints.ts, 32, 13)) +>x : Symbol(x, Decl(indexedAccessTypeConstraints.ts, 32, 42)) +>C : Symbol(C, Decl(indexedAccessTypeConstraints.ts, 32, 13)) +>y : Symbol(y, Decl(indexedAccessTypeConstraints.ts, 32, 47)) +>T : Symbol(T, Decl(indexedAccessTypeConstraints.ts, 32, 15)) + + x = y; +>x : Symbol(x, Decl(indexedAccessTypeConstraints.ts, 32, 42)) +>y : Symbol(y, Decl(indexedAccessTypeConstraints.ts, 32, 47)) +} + diff --git a/tests/baselines/reference/indexedAccessTypeConstraints.types b/tests/baselines/reference/indexedAccessTypeConstraints.types new file mode 100644 index 00000000000..5a2cbc4933f --- /dev/null +++ b/tests/baselines/reference/indexedAccessTypeConstraints.types @@ -0,0 +1,116 @@ +=== tests/cases/compiler/indexedAccessTypeConstraints.ts === + +// Repro from #14557 + +interface IData { +>IData : IData +>T : T + + content: T; +>content : T +>T : T +} + +type Data = { +>Data : { get: (prop: K) => T[K]; } +>T : T + + get: (prop: K) => T[K]; +>get : (prop: K) => T[K] +>K : K +>T : T +>prop : K +>K : K +>T : T +>K : K + +}; + +class Parent { +>Parent : Parent +>M : M + + private data: Data; +>data : { get: (prop: K) => M[K]; } +>Data : { get: (prop: K) => T[K]; } +>M : M + + getData(): Data { +>getData : () => { get: (prop: K) => M[K]; } +>Data : { get: (prop: K) => T[K]; } +>M : M + + return this.data; +>this.data : { get: (prop: K) => M[K]; } +>this : this +>data : { get: (prop: K) => M[K]; } + } +} + +export class Foo extends Parent> { +>Foo : Foo +>C : C +>Parent : Parent> +>IData : IData +>C : C + + getContent(): C { +>getContent : () => C +>C : C + + return this.getData().get('content'); +>this.getData().get('content') : C +>this.getData().get : (prop: K) => IData[K] +>this.getData() : { get: (prop: K) => IData[K]; } +>this.getData : () => { get: (prop: K) => IData[K]; } +>this : this +>getData : () => { get: (prop: K) => IData[K]; } +>get : (prop: K) => IData[K] +>'content' : "content" + } +} + +export class Bar> extends Parent { +>Bar : Bar +>C : C +>T : T +>IData : IData +>C : C +>Parent : Parent +>T : T + + getContent(): C { +>getContent : () => C +>C : C + + return this.getData().get('content'); +>this.getData().get('content') : T["content"] +>this.getData().get : (prop: K) => T[K] +>this.getData() : { get: (prop: K) => T[K]; } +>this.getData : () => { get: (prop: K) => T[K]; } +>this : this +>getData : () => { get: (prop: K) => T[K]; } +>get : (prop: K) => T[K] +>'content' : "content" + } +} + +// Repro from #14557 + +function foo(x: C, y: T['content']) { +>foo : (x: C, y: T["content"]) => void +>C : C +>T : T +>content : C +>C : C +>x : C +>C : C +>y : T["content"] +>T : T + + x = y; +>x = y : T["content"] +>x : C +>y : T["content"] +} + diff --git a/tests/cases/compiler/indexedAccessTypeConstraints.ts b/tests/cases/compiler/indexedAccessTypeConstraints.ts new file mode 100644 index 00000000000..c1c1bca198b --- /dev/null +++ b/tests/cases/compiler/indexedAccessTypeConstraints.ts @@ -0,0 +1,36 @@ +// @strict: true + +// Repro from #14557 + +interface IData { + content: T; +} + +type Data = { + get: (prop: K) => T[K]; +}; + +class Parent { + private data: Data; + getData(): Data { + return this.data; + } +} + +export class Foo extends Parent> { + getContent(): C { + return this.getData().get('content'); + } +} + +export class Bar> extends Parent { + getContent(): C { + return this.getData().get('content'); + } +} + +// Repro from #14557 + +function foo(x: C, y: T['content']) { + x = y; +} From 77c2a1d20d562ae5cd328151d595cb4044fd2b6b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 9 Mar 2017 15:25:44 -0800 Subject: [PATCH 130/167] allow passing --logFile and --logVerbosity parameter to tsserver (#14566) --- src/server/server.ts | 65 +++++++++++-------- .../typingsInstaller/nodeTypingsInstaller.ts | 10 ++- 2 files changed, 46 insertions(+), 29 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index 2c68963ec5c..475e5cdf920 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -131,6 +131,14 @@ namespace ts.server { constructor(private readonly logFilename: string, private readonly traceToConsole: boolean, private readonly level: LogLevel) { + if (this.logFilename) { + try { + this.fd = fs.openSync(this.logFilename, "w"); + } + catch(_) { + // swallow the error and keep logging disabled if file cannot be opened + } + } } static padStringRight(str: string, padding: string) { @@ -175,11 +183,6 @@ namespace ts.server { } msg(s: string, type: Msg.Types = Msg.Err) { - if (this.fd < 0) { - if (this.logFilename) { - this.fd = fs.openSync(this.logFilename, "w"); - } - } if (this.fd >= 0 || this.traceToConsole) { s = s + "\n"; const prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); @@ -410,6 +413,9 @@ namespace ts.server { } function parseLoggingEnvironmentString(logEnvStr: string): LogOptions { + if (!logEnvStr) { + return {}; + } const logEnv: LogOptions = { logToFile: true }; const args = logEnvStr.split(" "); const len = args.length - 1; @@ -422,8 +428,8 @@ namespace ts.server { logEnv.file = stripQuotes(value); break; case "-level": - const level: LogLevel = (LogLevel)[value]; - logEnv.detailLevel = typeof level === "number" ? level : LogLevel.normal; + const level = getLogLevel(value); + logEnv.detailLevel = level !== undefined ? level : LogLevel.normal; break; case "-traceToConsole": logEnv.traceToConsole = value.toLowerCase() === "true"; @@ -437,28 +443,32 @@ namespace ts.server { return logEnv; } - // TSS_LOG "{ level: "normal | verbose | terse", file?: string}" - function createLoggerFromEnv() { - let fileName: string = undefined; - let detailLevel = LogLevel.normal; - let traceToConsole = false; - const logEnvStr = process.env["TSS_LOG"]; - if (logEnvStr) { - const logEnv = parseLoggingEnvironmentString(logEnvStr); - if (logEnv.logToFile) { - if (logEnv.file) { - fileName = logEnv.file; - } - else { - fileName = __dirname + "/.log" + process.pid.toString(); + function getLogLevel(level: string) { + if (level) { + const l = level.toLowerCase(); + for (const name in LogLevel) { + if (isNaN(+name) && l === name.toLowerCase()) { + return LogLevel[name]; } } - if (logEnv.detailLevel) { - detailLevel = logEnv.detailLevel; - } - traceToConsole = logEnv.traceToConsole; } - return new Logger(fileName, traceToConsole, detailLevel); + return undefined; + } + + // TSS_LOG "{ level: "normal | verbose | terse", file?: string}" + function createLogger() { + const cmdLineLogFileName = findArgument("--logFile"); + const cmdLineVerbosity = getLogLevel(findArgument("--logVerbosity")); + const envLogOptions = parseLoggingEnvironmentString(process.env["TSS_LOG"]); + + const logFileName = cmdLineLogFileName + ? stripQuotes(cmdLineLogFileName) + : envLogOptions.logToFile + ? envLogOptions.file || (__dirname + "/.log" + process.pid.toString()) + : undefined; + + const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel; + return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity) } // This places log file in the directory containing editorServices.js // TODO: check that this location is writable @@ -555,7 +565,6 @@ namespace ts.server { // to increase the chunk size or decrease the interval // time dynamically to match the large reference set? const pollingWatchedFileSet = createPollingWatchedFileSet(); - const logger = createLoggerFromEnv(); const pending: Buffer[] = []; let canWrite = true; @@ -607,6 +616,8 @@ namespace ts.server { return s.length > 2 && s.charCodeAt(0) === CharacterCodes.slash && s.charCodeAt(1) === CharacterCodes.slash; } + const logger = createLogger(); + const sys = ts.sys; // use watchGuard process on Windows when node version is 4 or later const useWatchGuard = process.platform === "win32" && getNodeMajorVersion() >= 4; diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 0a69d701953..b9d08937467 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -13,14 +13,20 @@ namespace ts.server.typingsInstaller { } = require("path"); class FileLog implements Log { + private logEnabled = true; constructor(private readonly logFile?: string) { } isEnabled() { - return this.logFile !== undefined; + return this.logEnabled && this.logFile !== undefined; } writeLine(text: string) { - fs.appendFileSync(this.logFile, text + sys.newLine); + try { + fs.appendFileSync(this.logFile, text + sys.newLine); + } + catch(e) { + this.logEnabled = false; + } } } From 09fcf5b0cee4073404ce684b14b24040d98a01b3 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Tue, 24 Jan 2017 19:31:11 +0800 Subject: [PATCH 131/167] test(baseline): update references affected --- tests/baselines/reference/2dArrays.symbols | 4 +- tests/baselines/reference/2dArrays.types | 6 +- .../anyInferenceAnonymousFunctions.symbols | 8 +- .../anyInferenceAnonymousFunctions.types | 12 +- .../reference/argumentsAsPropertyName.symbols | 4 +- .../reference/argumentsAsPropertyName.types | 6 +- .../reference/arrayConcatMap.symbols | 4 +- .../baselines/reference/arrayConcatMap.types | 6 +- tests/baselines/reference/arrayFilter.symbols | 4 +- tests/baselines/reference/arrayFilter.types | 6 +- .../reference/bestChoiceType.symbols | 12 +- .../baselines/reference/bestChoiceType.types | 18 +-- ...kSwitchStatementIfCaseTypeIsString.symbols | 4 +- ...eckSwitchStatementIfCaseTypeIsString.types | 6 +- ...assExpressionWithStaticProperties3.symbols | 4 +- ...classExpressionWithStaticProperties3.types | 6 +- ...ExpressionWithStaticPropertiesES63.symbols | 4 +- ...ssExpressionWithStaticPropertiesES63.types | 6 +- ...mmaOperatorInConditionalExpression.symbols | 4 +- ...commaOperatorInConditionalExpression.types | 6 +- .../reference/commentInMethodCall.symbols | 4 +- .../reference/commentInMethodCall.types | 6 +- .../contextualSignatureInstantiation3.symbols | 12 +- .../contextualSignatureInstantiation3.types | 12 +- .../reference/contextuallyTypedIife.symbols | 16 +- .../reference/contextuallyTypedIife.types | 24 +-- .../contextuallyTypedIifeStrict.symbols | 16 +- .../contextuallyTypedIifeStrict.types | 24 +-- ...controlFlowDestructuringParameters.symbols | 4 +- .../controlFlowDestructuringParameters.types | 6 +- .../reference/declarationEmitPromise.symbols | 8 +- .../reference/declarationEmitPromise.types | 12 +- tests/baselines/reference/enumIndexer.symbols | 4 +- tests/baselines/reference/enumIndexer.types | 6 +- .../baselines/reference/genericArray1.symbols | 4 +- tests/baselines/reference/genericArray1.types | 6 +- .../reference/genericInference1.symbols | 4 +- .../reference/genericInference1.types | 6 +- .../genericMethodOverspecialization.symbols | 12 +- .../genericMethodOverspecialization.types | 18 +-- .../implementArrayInterface.errors.txt | 4 +- .../reference/inferenceLimit.symbols | 4 +- .../baselines/reference/inferenceLimit.types | 4 +- ...inferentialTypingWithFunctionType2.symbols | 4 +- .../inferentialTypingWithFunctionType2.types | 4 +- .../reference/keyofAndIndexedAccess.symbols | 4 +- .../reference/keyofAndIndexedAccess.types | 6 +- .../reference/mapOnTupleTypes01.symbols | 36 ++--- .../reference/mapOnTupleTypes01.types | 54 +++---- .../reference/mapOnTupleTypes02.symbols | 4 +- .../reference/mapOnTupleTypes02.types | 6 +- ...ibrary_NoErrorDuplicateLibOptions1.symbols | 4 +- ...eLibrary_NoErrorDuplicateLibOptions1.types | 4 +- ...ibrary_NoErrorDuplicateLibOptions2.symbols | 4 +- ...eLibrary_NoErrorDuplicateLibOptions2.types | 4 +- ...larizeLibrary_TargetES5UsingES6Lib.symbols | 4 +- ...dularizeLibrary_TargetES5UsingES6Lib.types | 4 +- ...larizeLibrary_TargetES6UsingES6Lib.symbols | 4 +- ...dularizeLibrary_TargetES6UsingES6Lib.types | 4 +- ...eLibrary_UsingES5LibAndES6ArrayLib.symbols | 4 +- ...izeLibrary_UsingES5LibAndES6ArrayLib.types | 4 +- ...ibES6ArrayLibES6WellknownSymbolLib.symbols | 4 +- ...5LibES6ArrayLibES6WellknownSymbolLib.types | 4 +- tests/baselines/reference/nestedSelf.symbols | 4 +- tests/baselines/reference/nestedSelf.types | 6 +- ...nContextuallyTypesFunctionParamter.symbols | 4 +- ...yInContextuallyTypesFunctionParamter.types | 6 +- .../reference/objectRestForOf.symbols | 4 +- .../baselines/reference/objectRestForOf.types | 6 +- ...arameterReferencedInObjectLiteral1.symbols | 8 +- ...nParameterReferencedInObjectLiteral1.types | 10 +- ...alizationsShouldNotAffectEachOther.symbols | 8 +- ...cializationsShouldNotAffectEachOther.types | 10 +- .../reference/targetTypeArgs.symbols | 24 +-- .../baselines/reference/targetTypeArgs.types | 36 ++--- .../targetTypeObjectLiteralToAny.symbols | 4 +- .../targetTypeObjectLiteralToAny.types | 6 +- .../reference/tsxSpreadChildren.symbols | 4 +- .../reference/tsxSpreadChildren.types | 6 +- ...ReferencedTypeAliasToTypeLiteral01.symbols | 4 +- ...lyReferencedTypeAliasToTypeLiteral01.types | 6 +- ...ReferencedTypeAliasToTypeLiteral02.symbols | 4 +- ...lyReferencedTypeAliasToTypeLiteral02.types | 6 +- tests/baselines/reference/typedArrays.symbols | 144 +++++++++--------- tests/baselines/reference/typedArrays.types | 144 +++++++++--------- 85 files changed, 483 insertions(+), 483 deletions(-) diff --git a/tests/baselines/reference/2dArrays.symbols b/tests/baselines/reference/2dArrays.symbols index 8d6b6b167e6..6f02cdcf963 100644 --- a/tests/baselines/reference/2dArrays.symbols +++ b/tests/baselines/reference/2dArrays.symbols @@ -25,11 +25,11 @@ class Board { >allShipsSunk : Symbol(Board.allShipsSunk, Decl(2dArrays.ts, 9, 18)) return this.ships.every(function (val) { return val.isSunk; }); ->this.ships.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>this.ships.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >this.ships : Symbol(Board.ships, Decl(2dArrays.ts, 7, 13)) >this : Symbol(Board, Decl(2dArrays.ts, 5, 1)) >ships : Symbol(Board.ships, Decl(2dArrays.ts, 7, 13)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >val : Symbol(val, Decl(2dArrays.ts, 12, 42)) >val.isSunk : Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12)) >val : Symbol(val, Decl(2dArrays.ts, 12, 42)) diff --git a/tests/baselines/reference/2dArrays.types b/tests/baselines/reference/2dArrays.types index 00805899294..cd5ddc0efa5 100644 --- a/tests/baselines/reference/2dArrays.types +++ b/tests/baselines/reference/2dArrays.types @@ -26,12 +26,12 @@ class Board { return this.ships.every(function (val) { return val.isSunk; }); >this.ships.every(function (val) { return val.isSunk; }) : boolean ->this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean +>this.ships.every : { (callbackfn: (this: undefined, value: Ship, index: number, array: Ship[]) => boolean): boolean; (callbackfn: (this: undefined, value: Ship, index: number, array: Ship[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Ship, index: number, array: Ship[]) => boolean, thisArg: Z): boolean; } >this.ships : Ship[] >this : this >ships : Ship[] ->every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean ->function (val) { return val.isSunk; } : (val: Ship) => boolean +>every : { (callbackfn: (this: undefined, value: Ship, index: number, array: Ship[]) => boolean): boolean; (callbackfn: (this: undefined, value: Ship, index: number, array: Ship[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Ship, index: number, array: Ship[]) => boolean, thisArg: Z): boolean; } +>function (val) { return val.isSunk; } : (this: undefined, val: Ship) => boolean >val : Ship >val.isSunk : boolean >val : Ship diff --git a/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols b/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols index ff576a36423..750c7ba85af 100644 --- a/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols +++ b/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols @@ -35,16 +35,16 @@ paired.reduce((b3, b4) => b3.concat({}), []); >b3 : Symbol(b3, Decl(anyInferenceAnonymousFunctions.ts, 13, 15)) paired.map((c1) => c1.count); ->paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12)) >c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12)) paired.map(function (c2) { return c2.count; }); ->paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21)) >c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21)) diff --git a/tests/baselines/reference/anyInferenceAnonymousFunctions.types b/tests/baselines/reference/anyInferenceAnonymousFunctions.types index 1f3bb78f958..ee176215421 100644 --- a/tests/baselines/reference/anyInferenceAnonymousFunctions.types +++ b/tests/baselines/reference/anyInferenceAnonymousFunctions.types @@ -57,10 +57,10 @@ paired.reduce((b3, b4) => b3.concat({}), []); paired.map((c1) => c1.count); >paired.map((c1) => c1.count) : any[] ->paired.map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>paired.map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >paired : any[] ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } ->(c1) => c1.count : (c1: any) => any +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>(c1) => c1.count : (this: undefined, c1: any) => any >c1 : any >c1.count : any >c1 : any @@ -68,10 +68,10 @@ paired.map((c1) => c1.count); paired.map(function (c2) { return c2.count; }); >paired.map(function (c2) { return c2.count; }) : any[] ->paired.map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>paired.map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >paired : any[] ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } ->function (c2) { return c2.count; } : (c2: any) => any +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>function (c2) { return c2.count; } : (this: undefined, c2: any) => any >c2 : any >c2.count : any >c2 : any diff --git a/tests/baselines/reference/argumentsAsPropertyName.symbols b/tests/baselines/reference/argumentsAsPropertyName.symbols index 1e3e41abb6e..a17c660374c 100644 --- a/tests/baselines/reference/argumentsAsPropertyName.symbols +++ b/tests/baselines/reference/argumentsAsPropertyName.symbols @@ -34,8 +34,8 @@ function myFunction(myType: MyType) { >x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) [1, 2, 3].forEach(function(j) { use(x); }) ->[1, 2, 3].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>[1, 2, 3].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >j : Symbol(j, Decl(argumentsAsPropertyName.ts, 12, 35)) >use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) >x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) diff --git a/tests/baselines/reference/argumentsAsPropertyName.types b/tests/baselines/reference/argumentsAsPropertyName.types index d0aaaa1cc72..00773d2a3cf 100644 --- a/tests/baselines/reference/argumentsAsPropertyName.types +++ b/tests/baselines/reference/argumentsAsPropertyName.types @@ -42,13 +42,13 @@ function myFunction(myType: MyType) { [1, 2, 3].forEach(function(j) { use(x); }) >[1, 2, 3].forEach(function(j) { use(x); }) : void ->[1, 2, 3].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>[1, 2, 3].forEach : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } >[1, 2, 3] : number[] >1 : 1 >2 : 2 >3 : 3 ->forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void ->function(j) { use(x); } : (j: number) => void +>forEach : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } +>function(j) { use(x); } : (this: undefined, j: number) => void >j : number >use(x) : any >use : (s: any) => any diff --git a/tests/baselines/reference/arrayConcatMap.symbols b/tests/baselines/reference/arrayConcatMap.symbols index c3df6bed533..1b26708ae94 100644 --- a/tests/baselines/reference/arrayConcatMap.symbols +++ b/tests/baselines/reference/arrayConcatMap.symbols @@ -1,14 +1,14 @@ === tests/cases/compiler/arrayConcatMap.ts === var x = [].concat([{ a: 1 }], [{ a: 2 }]) >x : Symbol(x, Decl(arrayConcatMap.ts, 0, 3)) ->[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(arrayConcatMap.ts, 0, 20)) >a : Symbol(a, Decl(arrayConcatMap.ts, 0, 32)) .map(b => b.a); ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15)) >b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15)) diff --git a/tests/baselines/reference/arrayConcatMap.types b/tests/baselines/reference/arrayConcatMap.types index 10e0a74c16d..da4e998f92c 100644 --- a/tests/baselines/reference/arrayConcatMap.types +++ b/tests/baselines/reference/arrayConcatMap.types @@ -2,7 +2,7 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }]) >x : any[] >[].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a) : any[] ->[].concat([{ a: 1 }], [{ a: 2 }]) .map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>[].concat([{ a: 1 }], [{ a: 2 }]) .map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >[].concat([{ a: 1 }], [{ a: 2 }]) : any[] >[].concat : { (...items: any[][]): any[]; (...items: any[]): any[]; } >[] : undefined[] @@ -17,8 +17,8 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }]) >2 : 2 .map(b => b.a); ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } ->b => b.a : (b: any) => any +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>b => b.a : (this: undefined, b: any) => any >b : any >b.a : any >b : any diff --git a/tests/baselines/reference/arrayFilter.symbols b/tests/baselines/reference/arrayFilter.symbols index fcdd39117a7..81d92ba04b6 100644 --- a/tests/baselines/reference/arrayFilter.symbols +++ b/tests/baselines/reference/arrayFilter.symbols @@ -14,9 +14,9 @@ var foo = [ ] foo.filter(x => x.name); //should accepted all possible types not only boolean! ->foo.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --)) +>foo.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >foo : Symbol(foo, Decl(arrayFilter.ts, 0, 3)) ->filter : Symbol(Array.filter, Decl(lib.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(arrayFilter.ts, 6, 11)) >x.name : Symbol(name, Decl(arrayFilter.ts, 1, 5)) >x : Symbol(x, Decl(arrayFilter.ts, 6, 11)) diff --git a/tests/baselines/reference/arrayFilter.types b/tests/baselines/reference/arrayFilter.types index 43ef4161a06..de11296f832 100644 --- a/tests/baselines/reference/arrayFilter.types +++ b/tests/baselines/reference/arrayFilter.types @@ -22,10 +22,10 @@ var foo = [ foo.filter(x => x.name); //should accepted all possible types not only boolean! >foo.filter(x => x.name) : { name: string; }[] ->foo.filter : (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any) => { name: string; }[] +>foo.filter : { (callbackfn: (this: undefined, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: undefined, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } >foo : { name: string; }[] ->filter : (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any) => { name: string; }[] ->x => x.name : (x: { name: string; }) => string +>filter : { (callbackfn: (this: undefined, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: undefined, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } +>x => x.name : (this: undefined, x: { name: string; }) => string >x : { name: string; } >x.name : string >x : { name: string; } diff --git a/tests/baselines/reference/bestChoiceType.symbols b/tests/baselines/reference/bestChoiceType.symbols index 737ba35b520..45f4342992e 100644 --- a/tests/baselines/reference/bestChoiceType.symbols +++ b/tests/baselines/reference/bestChoiceType.symbols @@ -3,10 +3,10 @@ // Repro from #10041 (''.match(/ /) || []).map(s => s.toLowerCase()); ->(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 3, 26)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 3, 26)) @@ -28,9 +28,9 @@ function f1() { let z = y.map(s => s.toLowerCase()); >z : Symbol(z, Decl(bestChoiceType.ts, 10, 7)) ->y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(bestChoiceType.ts, 9, 7)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 10, 18)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 10, 18)) @@ -52,9 +52,9 @@ function f2() { let z = y.map(s => s.toLowerCase()); >z : Symbol(z, Decl(bestChoiceType.ts, 16, 7)) ->y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(bestChoiceType.ts, 15, 7)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 16, 18)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 16, 18)) diff --git a/tests/baselines/reference/bestChoiceType.types b/tests/baselines/reference/bestChoiceType.types index 07b61fc9f84..3a540e97d59 100644 --- a/tests/baselines/reference/bestChoiceType.types +++ b/tests/baselines/reference/bestChoiceType.types @@ -4,7 +4,7 @@ (''.match(/ /) || []).map(s => s.toLowerCase()); >(''.match(/ /) || []).map(s => s.toLowerCase()) : string[] ->(''.match(/ /) || []).map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>(''.match(/ /) || []).map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >(''.match(/ /) || []) : RegExpMatchArray >''.match(/ /) || [] : RegExpMatchArray >''.match(/ /) : RegExpMatchArray | null @@ -13,8 +13,8 @@ >match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } >/ / : RegExp >[] : never[] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->s => s.toLowerCase() : (s: string) => string +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>s => s.toLowerCase() : (this: undefined, s: string) => string >s : string >s.toLowerCase() : string >s.toLowerCase : () => string @@ -43,10 +43,10 @@ function f1() { let z = y.map(s => s.toLowerCase()); >z : string[] >y.map(s => s.toLowerCase()) : string[] ->y.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>y.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >y : RegExpMatchArray ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->s => s.toLowerCase() : (s: string) => string +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>s => s.toLowerCase() : (this: undefined, s: string) => string >s : string >s.toLowerCase() : string >s.toLowerCase : () => string @@ -75,10 +75,10 @@ function f2() { let z = y.map(s => s.toLowerCase()); >z : string[] >y.map(s => s.toLowerCase()) : string[] ->y.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>y.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >y : RegExpMatchArray ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->s => s.toLowerCase() : (s: string) => string +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>s => s.toLowerCase() : (this: undefined, s: string) => string >s : string >s.toLowerCase() : string >s.toLowerCase : () => string diff --git a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols index 2a6ba238b4b..33f8f88f9e0 100644 --- a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols +++ b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols @@ -12,9 +12,9 @@ class A { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) x.forEach((v) => { ->x.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>x.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 3, 9)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 4, 19)) switch(v) { diff --git a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types index 30f584894fc..7bae17fb922 100644 --- a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types +++ b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types @@ -13,10 +13,10 @@ class A { x.forEach((v) => { >x.forEach((v) => { switch(v) { case "test": use(this); } }) : void ->x.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>x.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } >x : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->(v) => { switch(v) { case "test": use(this); } } : (v: string) => void +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>(v) => { switch(v) { case "test": use(this); } } : (this: undefined, v: string) => void >v : string switch(v) { diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.symbols b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols index ff9b7b0d311..4c7750c12a7 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties3.symbols +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols @@ -31,9 +31,9 @@ for (let i = 0; i < 3; i++) { }); } arr.forEach(C => console.log(C.y())); ->arr.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>arr.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 9, 12)) >console : Symbol(console, Decl(classExpressionWithStaticProperties3.ts, 1, 11)) >C.y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12)) diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.types b/tests/baselines/reference/classExpressionWithStaticProperties3.types index b7f6102c8b7..dbbb1f378a8 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties3.types +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.types @@ -42,10 +42,10 @@ for (let i = 0; i < 3; i++) { } arr.forEach(C => console.log(C.y())); >arr.forEach(C => console.log(C.y())) : void ->arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>arr.forEach : { (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } >arr : { y(): number; }[] ->forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void ->C => console.log(C.y()) : (C: { y(): number; }) => any +>forEach : { (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } +>C => console.log(C.y()) : (this: undefined, C: { y(): number; }) => any >C : { y(): number; } >console.log(C.y()) : any >console.log : any diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols index f1a7fa807f5..94ea5cfaa8c 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols @@ -31,9 +31,9 @@ for (let i = 0; i < 3; i++) { }); } arr.forEach(C => console.log(C.y())); ->arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12)) >console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11)) >C.y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12)) diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types index 3bc780785aa..b725df6fd74 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types @@ -42,10 +42,10 @@ for (let i = 0; i < 3; i++) { } arr.forEach(C => console.log(C.y())); >arr.forEach(C => console.log(C.y())) : void ->arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>arr.forEach : { (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } >arr : { y(): number; }[] ->forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void ->C => console.log(C.y()) : (C: { y(): number; }) => any +>forEach : { (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } +>C => console.log(C.y()) : (this: undefined, C: { y(): number; }) => any >C : { y(): number; } >console.log(C.y()) : any >console.log : any diff --git a/tests/baselines/reference/commaOperatorInConditionalExpression.symbols b/tests/baselines/reference/commaOperatorInConditionalExpression.symbols index 18f749c5c5c..cb124f21f15 100644 --- a/tests/baselines/reference/commaOperatorInConditionalExpression.symbols +++ b/tests/baselines/reference/commaOperatorInConditionalExpression.symbols @@ -4,8 +4,8 @@ function f (m: string) { >m : Symbol(m, Decl(commaOperatorInConditionalExpression.ts, 0, 12)) [1, 2, 3].map(i => { ->[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >i : Symbol(i, Decl(commaOperatorInConditionalExpression.ts, 1, 18)) return true? { [m]: i } : { [m]: i + 1 } diff --git a/tests/baselines/reference/commaOperatorInConditionalExpression.types b/tests/baselines/reference/commaOperatorInConditionalExpression.types index f46282f9b6b..de8a95cd6c3 100644 --- a/tests/baselines/reference/commaOperatorInConditionalExpression.types +++ b/tests/baselines/reference/commaOperatorInConditionalExpression.types @@ -5,13 +5,13 @@ function f (m: string) { [1, 2, 3].map(i => { >[1, 2, 3].map(i => { return true? { [m]: i } : { [m]: i + 1 } }) : { [x: string]: number; }[] ->[1, 2, 3].map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>[1, 2, 3].map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >[1, 2, 3] : number[] >1 : 1 >2 : 2 >3 : 3 ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->i => { return true? { [m]: i } : { [m]: i + 1 } } : (i: number) => { [x: string]: number; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>i => { return true? { [m]: i } : { [m]: i + 1 } } : (this: undefined, i: number) => { [x: string]: number; } >i : number return true? { [m]: i } : { [m]: i + 1 } diff --git a/tests/baselines/reference/commentInMethodCall.symbols b/tests/baselines/reference/commentInMethodCall.symbols index 1ef762da871..e082d24daf3 100644 --- a/tests/baselines/reference/commentInMethodCall.symbols +++ b/tests/baselines/reference/commentInMethodCall.symbols @@ -4,9 +4,9 @@ var s: string[]; >s : Symbol(s, Decl(commentInMethodCall.ts, 1, 3)) s.map(// do something ->s.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>s.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(commentInMethodCall.ts, 1, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) function () { }); diff --git a/tests/baselines/reference/commentInMethodCall.types b/tests/baselines/reference/commentInMethodCall.types index a97b0319777..eebbc15823e 100644 --- a/tests/baselines/reference/commentInMethodCall.types +++ b/tests/baselines/reference/commentInMethodCall.types @@ -5,10 +5,10 @@ var s: string[]; s.map(// do something >s.map(// do something function () { }) : void[] ->s.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>s.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >s : string[] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } function () { }); ->function () { } : () => void +>function () { } : (this: undefined) => void diff --git a/tests/baselines/reference/contextualSignatureInstantiation3.symbols b/tests/baselines/reference/contextualSignatureInstantiation3.symbols index 50dac0b5d67..a9653673ff2 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation3.symbols +++ b/tests/baselines/reference/contextualSignatureInstantiation3.symbols @@ -12,9 +12,9 @@ function map(items: T[], f: (x: T) => U): U[]{ >U : Symbol(U, Decl(contextualSignatureInstantiation3.ts, 0, 15)) return items.map(f); ->items.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>items.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >items : Symbol(items, Decl(contextualSignatureInstantiation3.ts, 0, 19)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >f : Symbol(f, Decl(contextualSignatureInstantiation3.ts, 0, 30)) } @@ -47,9 +47,9 @@ var v1: number[]; var v1 = xs.map(identity); // Error if not number[] >v1 : Symbol(v1, Decl(contextualSignatureInstantiation3.ts, 15, 3), Decl(contextualSignatureInstantiation3.ts, 16, 3), Decl(contextualSignatureInstantiation3.ts, 17, 3)) ->xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >identity : Symbol(identity, Decl(contextualSignatureInstantiation3.ts, 2, 1)) var v1 = map(xs, identity); // Error if not number[] @@ -63,9 +63,9 @@ var v2: number[][]; var v2 = xs.map(singleton); // Error if not number[][] >v2 : Symbol(v2, Decl(contextualSignatureInstantiation3.ts, 19, 3), Decl(contextualSignatureInstantiation3.ts, 20, 3), Decl(contextualSignatureInstantiation3.ts, 21, 3)) ->xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >singleton : Symbol(singleton, Decl(contextualSignatureInstantiation3.ts, 6, 1)) var v2 = map(xs, singleton); // Error if not number[][] diff --git a/tests/baselines/reference/contextualSignatureInstantiation3.types b/tests/baselines/reference/contextualSignatureInstantiation3.types index 409c685215d..dcb7284ceaa 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation3.types +++ b/tests/baselines/reference/contextualSignatureInstantiation3.types @@ -13,9 +13,9 @@ function map(items: T[], f: (x: T) => U): U[]{ return items.map(f); >items.map(f) : U[] ->items.map : { (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; } +>items.map : { (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } >items : T[] ->map : { (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; } +>map : { (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } >f : (x: T) => U } @@ -54,9 +54,9 @@ var v1: number[]; var v1 = xs.map(identity); // Error if not number[] >v1 : number[] >xs.map(identity) : number[] ->xs.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>xs.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >xs : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >identity : (x: T) => T var v1 = map(xs, identity); // Error if not number[] @@ -72,9 +72,9 @@ var v2: number[][]; var v2 = xs.map(singleton); // Error if not number[][] >v2 : number[][] >xs.map(singleton) : number[][] ->xs.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>xs.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >xs : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >singleton : (x: T) => T[] var v2 = map(xs, singleton); // Error if not number[][] diff --git a/tests/baselines/reference/contextuallyTypedIife.symbols b/tests/baselines/reference/contextuallyTypedIife.symbols index 7a73beaad16..96e57c1f62f 100644 --- a/tests/baselines/reference/contextuallyTypedIife.symbols +++ b/tests/baselines/reference/contextuallyTypedIife.symbols @@ -47,25 +47,25 @@ // rest parameters ((...numbers) => numbers.every(n => n > 0))(5,6,7); >numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 17, 2)) ->numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 17, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 31)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 31)) ((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); >mixed : Symbol(mixed, Decl(contextuallyTypedIife.ts, 18, 2)) ->mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >mixed : Symbol(mixed, Decl(contextuallyTypedIife.ts, 18, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 27)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 27)) ((...noNumbers) => noNumbers.some(n => n > 0))(); >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 19, 2)) ->noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 19, 2)) ->some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 19, 34)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 19, 34)) @@ -73,9 +73,9 @@ >first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2)) >rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8)) >first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2)) ->rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43)) diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index 676755fb341..b8c59a618b8 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -105,10 +105,10 @@ >(...numbers) => numbers.every(n => n > 0) : (...numbers: number[]) => boolean >numbers : number[] >numbers.every(n => n > 0) : boolean ->numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers.every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } >numbers : number[] ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->n => n > 0 : (n: number) => boolean +>every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } +>n => n > 0 : (this: undefined, n: number) => boolean >n : number >n > 0 : boolean >n : number @@ -123,10 +123,10 @@ >(...mixed) => mixed.every(n => !!n) : (...mixed: (string | number)[]) => boolean >mixed : (string | number)[] >mixed.every(n => !!n) : boolean ->mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed.every : { (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } >mixed : (string | number)[] ->every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean ->n => !!n : (n: string | number) => boolean +>every : { (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } +>n => !!n : (this: undefined, n: string | number) => boolean >n : string | number >!!n : boolean >!n : boolean @@ -141,10 +141,10 @@ >(...noNumbers) => noNumbers.some(n => n > 0) : (...noNumbers: any[]) => boolean >noNumbers : any[] >noNumbers.some(n => n > 0) : boolean ->noNumbers.some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>noNumbers.some : { (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } >noNumbers : any[] ->some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean ->n => n > 0 : (n: any) => boolean +>some : { (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } +>n => n > 0 : (this: undefined, n: any) => boolean >n : any >n > 0 : boolean >n : any @@ -160,10 +160,10 @@ >first : number >[] : undefined[] >rest.map(n => n > 0) : boolean[] ->rest.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>rest.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >rest : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n > 0 : (n: number) => boolean +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n > 0 : (this: undefined, n: number) => boolean >n : number >n > 0 : boolean >n : number diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.symbols b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols index f76c9caa104..62b585122dd 100644 --- a/tests/baselines/reference/contextuallyTypedIifeStrict.symbols +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols @@ -47,25 +47,25 @@ // rest parameters ((...numbers) => numbers.every(n => n > 0))(5,6,7); >numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2)) ->numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31)) ((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); >mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2)) ->mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27)) ((...noNumbers) => noNumbers.some(n => n > 0))(); >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2)) ->noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2)) ->some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) @@ -73,9 +73,9 @@ >first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2)) >rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8)) >first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2)) ->rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.types b/tests/baselines/reference/contextuallyTypedIifeStrict.types index cbeee53ec2e..0f888f98277 100644 --- a/tests/baselines/reference/contextuallyTypedIifeStrict.types +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.types @@ -105,10 +105,10 @@ >(...numbers) => numbers.every(n => n > 0) : (...numbers: number[]) => boolean >numbers : number[] >numbers.every(n => n > 0) : boolean ->numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers.every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } >numbers : number[] ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->n => n > 0 : (n: number) => boolean +>every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } +>n => n > 0 : (this: undefined, n: number) => boolean >n : number >n > 0 : boolean >n : number @@ -123,10 +123,10 @@ >(...mixed) => mixed.every(n => !!n) : (...mixed: (string | number)[]) => boolean >mixed : (string | number)[] >mixed.every(n => !!n) : boolean ->mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed.every : { (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } >mixed : (string | number)[] ->every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean ->n => !!n : (n: string | number) => boolean +>every : { (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } +>n => !!n : (this: undefined, n: string | number) => boolean >n : string | number >!!n : boolean >!n : boolean @@ -141,10 +141,10 @@ >(...noNumbers) => noNumbers.some(n => n > 0) : (...noNumbers: any[]) => boolean >noNumbers : any[] >noNumbers.some(n => n > 0) : boolean ->noNumbers.some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>noNumbers.some : { (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } >noNumbers : any[] ->some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean ->n => n > 0 : (n: any) => boolean +>some : { (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } +>n => n > 0 : (this: undefined, n: any) => boolean >n : any >n > 0 : boolean >n : any @@ -160,10 +160,10 @@ >first : number >[] : never[] >rest.map(n => n > 0) : boolean[] ->rest.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>rest.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >rest : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n > 0 : (n: number) => boolean +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n > 0 : (this: undefined, n: number) => boolean >n : number >n > 0 : boolean >n : number diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.symbols b/tests/baselines/reference/controlFlowDestructuringParameters.symbols index 58d2edfc12c..1874c16c3d3 100644 --- a/tests/baselines/reference/controlFlowDestructuringParameters.symbols +++ b/tests/baselines/reference/controlFlowDestructuringParameters.symbols @@ -3,9 +3,9 @@ [{ x: 1 }].map( ->[{ x: 1 }].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[{ x: 1 }].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 3, 2)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ({ x }) => x >x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 4, 4)) diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.types b/tests/baselines/reference/controlFlowDestructuringParameters.types index c38a8fb1aa4..d1adadfee17 100644 --- a/tests/baselines/reference/controlFlowDestructuringParameters.types +++ b/tests/baselines/reference/controlFlowDestructuringParameters.types @@ -4,15 +4,15 @@ [{ x: 1 }].map( >[{ x: 1 }].map( ({ x }) => x) : number[] ->[{ x: 1 }].map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; } +>[{ x: 1 }].map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): U[]; (callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): U[]; } >[{ x: 1 }] : { x: number; }[] >{ x: 1 } : { x: number; } >x : number >1 : 1 ->map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; } +>map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): U[]; (callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): U[]; } ({ x }) => x ->({ x }) => x : ({x}: { x: number; }) => number +>({ x }) => x : (this: undefined, {x}: { x: number; }) => number >x : number >x : number diff --git a/tests/baselines/reference/declarationEmitPromise.symbols b/tests/baselines/reference/declarationEmitPromise.symbols index 2c37e1dfa78..23d00ec6386 100644 --- a/tests/baselines/reference/declarationEmitPromise.symbols +++ b/tests/baselines/reference/declarationEmitPromise.symbols @@ -40,13 +40,13 @@ export async function runSampleWorks( >bluebird.all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 1, 26)) >bluebird : Symbol(bluebird, Decl(declarationEmitPromise.ts, 0, 0)) >all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 1, 26)) ->[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --)) +>[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >a : Symbol(a, Decl(declarationEmitPromise.ts, 5, 52)) >b : Symbol(b, Decl(declarationEmitPromise.ts, 6, 19)) >c : Symbol(c, Decl(declarationEmitPromise.ts, 6, 36)) >d : Symbol(d, Decl(declarationEmitPromise.ts, 6, 53)) >e : Symbol(e, Decl(declarationEmitPromise.ts, 6, 70)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 7, 68)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 7, 68)) @@ -112,13 +112,13 @@ export async function runSampleBreaks( >bluebird.all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 1, 26)) >bluebird : Symbol(bluebird, Decl(declarationEmitPromise.ts, 0, 0)) >all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 1, 26)) ->[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --)) +>[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >a : Symbol(a, Decl(declarationEmitPromise.ts, 14, 53)) >b : Symbol(b, Decl(declarationEmitPromise.ts, 15, 19)) >c : Symbol(c, Decl(declarationEmitPromise.ts, 15, 36)) >d : Symbol(d, Decl(declarationEmitPromise.ts, 15, 53)) >e : Symbol(e, Decl(declarationEmitPromise.ts, 15, 70)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 16, 68)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 16, 68)) diff --git a/tests/baselines/reference/declarationEmitPromise.types b/tests/baselines/reference/declarationEmitPromise.types index 4edaa444326..3cdf63ef478 100644 --- a/tests/baselines/reference/declarationEmitPromise.types +++ b/tests/baselines/reference/declarationEmitPromise.types @@ -45,15 +45,15 @@ export async function runSampleWorks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any) => bluebird[] +>[a, b, c, d, e].filter : { (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any) => bluebird[] ->el => !!el : (el: bluebird) => boolean +>filter : { (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } +>el => !!el : (this: undefined, el: bluebird) => boolean >el : bluebird >!!el : boolean >!el : boolean @@ -130,15 +130,15 @@ export async function runSampleBreaks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any) => bluebird[] +>[a, b, c, d, e].filter : { (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any) => bluebird[] ->el => !!el : (el: bluebird) => boolean +>filter : { (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } +>el => !!el : (this: undefined, el: bluebird) => boolean >el : bluebird >!!el : boolean >!el : boolean diff --git a/tests/baselines/reference/enumIndexer.symbols b/tests/baselines/reference/enumIndexer.symbols index 79baee66498..cf87cb106d1 100644 --- a/tests/baselines/reference/enumIndexer.symbols +++ b/tests/baselines/reference/enumIndexer.symbols @@ -19,9 +19,9 @@ var enumValue = MyEnumType.foo; var x = _arr.map(o => MyEnumType[o.key] === enumValue); // these are not same type >x : Symbol(x, Decl(enumIndexer.ts, 5, 3)) ->_arr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>_arr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >_arr : Symbol(_arr, Decl(enumIndexer.ts, 3, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >o : Symbol(o, Decl(enumIndexer.ts, 5, 17)) >MyEnumType : Symbol(MyEnumType, Decl(enumIndexer.ts, 0, 0)) >o.key : Symbol(key, Decl(enumIndexer.ts, 3, 13)) diff --git a/tests/baselines/reference/enumIndexer.types b/tests/baselines/reference/enumIndexer.types index 3abd7eaaa4c..981ad5c8c81 100644 --- a/tests/baselines/reference/enumIndexer.types +++ b/tests/baselines/reference/enumIndexer.types @@ -25,10 +25,10 @@ var enumValue = MyEnumType.foo; var x = _arr.map(o => MyEnumType[o.key] === enumValue); // these are not same type >x : boolean[] >_arr.map(o => MyEnumType[o.key] === enumValue) : boolean[] ->_arr.map : { (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): U[]; } +>_arr.map : { (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): U[]; (callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): U[]; } >_arr : { key: string; }[] ->map : { (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): U[]; } ->o => MyEnumType[o.key] === enumValue : (o: { key: string; }) => boolean +>map : { (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): U[]; (callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): U[]; } +>o => MyEnumType[o.key] === enumValue : (this: undefined, o: { key: string; }) => boolean >o : { key: string; } >MyEnumType[o.key] === enumValue : boolean >MyEnumType[o.key] : any diff --git a/tests/baselines/reference/genericArray1.symbols b/tests/baselines/reference/genericArray1.symbols index a96b487f1d7..f548f34e553 100644 --- a/tests/baselines/reference/genericArray1.symbols +++ b/tests/baselines/reference/genericArray1.symbols @@ -13,8 +13,8 @@ interface String{ var lengths = ["a", "b", "c"].map(x => x.length); >lengths : Symbol(lengths, Decl(genericArray1.ts, 12, 3)) ->["a", "b", "c"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>["a", "b", "c"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(genericArray1.ts, 12, 34)) >x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(genericArray1.ts, 12, 34)) diff --git a/tests/baselines/reference/genericArray1.types b/tests/baselines/reference/genericArray1.types index 68d691a96e3..b893d9778fc 100644 --- a/tests/baselines/reference/genericArray1.types +++ b/tests/baselines/reference/genericArray1.types @@ -14,13 +14,13 @@ interface String{ var lengths = ["a", "b", "c"].map(x => x.length); >lengths : number[] >["a", "b", "c"].map(x => x.length) : number[] ->["a", "b", "c"].map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>["a", "b", "c"].map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >["a", "b", "c"] : string[] >"a" : "a" >"b" : "b" >"c" : "c" ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->x => x.length : (x: string) => number +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>x => x.length : (this: undefined, x: string) => number >x : string >x.length : number >x : string diff --git a/tests/baselines/reference/genericInference1.symbols b/tests/baselines/reference/genericInference1.symbols index 7fc39ac556f..ecc9c811d76 100644 --- a/tests/baselines/reference/genericInference1.symbols +++ b/tests/baselines/reference/genericInference1.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/genericInference1.ts === ['a', 'b', 'c'].map(x => x.length); ->['a', 'b', 'c'].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>['a', 'b', 'c'].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(genericInference1.ts, 0, 20)) >x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(genericInference1.ts, 0, 20)) diff --git a/tests/baselines/reference/genericInference1.types b/tests/baselines/reference/genericInference1.types index ddf8d762000..64ff2c399cd 100644 --- a/tests/baselines/reference/genericInference1.types +++ b/tests/baselines/reference/genericInference1.types @@ -1,13 +1,13 @@ === tests/cases/compiler/genericInference1.ts === ['a', 'b', 'c'].map(x => x.length); >['a', 'b', 'c'].map(x => x.length) : number[] ->['a', 'b', 'c'].map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>['a', 'b', 'c'].map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >['a', 'b', 'c'] : string[] >'a' : "a" >'b' : "b" >'c' : "c" ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->x => x.length : (x: string) => number +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>x => x.length : (this: undefined, x: string) => number >x : string >x.length : number >x : string diff --git a/tests/baselines/reference/genericMethodOverspecialization.symbols b/tests/baselines/reference/genericMethodOverspecialization.symbols index 5fd2a0479e6..55ff9cb5afb 100644 --- a/tests/baselines/reference/genericMethodOverspecialization.symbols +++ b/tests/baselines/reference/genericMethodOverspecialization.symbols @@ -27,9 +27,9 @@ interface Document { var elements = names.map(function (name) { >elements : Symbol(elements, Decl(genericMethodOverspecialization.ts, 12, 3)) ->names.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>names.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >names : Symbol(names, Decl(genericMethodOverspecialization.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >name : Symbol(name, Decl(genericMethodOverspecialization.ts, 12, 35)) return document.getElementById(name); @@ -43,9 +43,9 @@ var elements = names.map(function (name) { var xxx = elements.filter(function (e) { >xxx : Symbol(xxx, Decl(genericMethodOverspecialization.ts, 17, 3)) ->elements.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --)) +>elements.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >elements : Symbol(elements, Decl(genericMethodOverspecialization.ts, 12, 3)) ->filter : Symbol(Array.filter, Decl(lib.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >e : Symbol(e, Decl(genericMethodOverspecialization.ts, 17, 36)) return !e.isDisabled; @@ -57,9 +57,9 @@ var xxx = elements.filter(function (e) { var widths:number[] = elements.map(function (e) { // should not error >widths : Symbol(widths, Decl(genericMethodOverspecialization.ts, 21, 3)) ->elements.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>elements.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >elements : Symbol(elements, Decl(genericMethodOverspecialization.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >e : Symbol(e, Decl(genericMethodOverspecialization.ts, 21, 45)) return e.clientWidth; diff --git a/tests/baselines/reference/genericMethodOverspecialization.types b/tests/baselines/reference/genericMethodOverspecialization.types index 0f90bd34e2e..36b710b742c 100644 --- a/tests/baselines/reference/genericMethodOverspecialization.types +++ b/tests/baselines/reference/genericMethodOverspecialization.types @@ -34,10 +34,10 @@ interface Document { var elements = names.map(function (name) { >elements : HTMLElement[] >names.map(function (name) { return document.getElementById(name);}) : HTMLElement[] ->names.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>names.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >names : string[] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->function (name) { return document.getElementById(name);} : (name: string) => HTMLElement +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>function (name) { return document.getElementById(name);} : (this: undefined, name: string) => HTMLElement >name : string return document.getElementById(name); @@ -53,10 +53,10 @@ var elements = names.map(function (name) { var xxx = elements.filter(function (e) { >xxx : HTMLElement[] >elements.filter(function (e) { return !e.isDisabled;}) : HTMLElement[] ->elements.filter : (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any) => HTMLElement[] +>elements.filter : { (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => any): HTMLElement[]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: undefined): HTMLElement[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: Z): HTMLElement[]; } >elements : HTMLElement[] ->filter : (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any) => HTMLElement[] ->function (e) { return !e.isDisabled;} : (e: HTMLElement) => boolean +>filter : { (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => any): HTMLElement[]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: undefined): HTMLElement[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: Z): HTMLElement[]; } +>function (e) { return !e.isDisabled;} : (this: undefined, e: HTMLElement) => boolean >e : HTMLElement return !e.isDisabled; @@ -70,10 +70,10 @@ var xxx = elements.filter(function (e) { var widths:number[] = elements.map(function (e) { // should not error >widths : number[] >elements.map(function (e) { // should not error return e.clientWidth;}) : number[] ->elements.map : { (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): U[]; } +>elements.map : { (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): U[]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): U[]; } >elements : HTMLElement[] ->map : { (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): U[]; } ->function (e) { // should not error return e.clientWidth;} : (e: HTMLElement) => number +>map : { (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): U[]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): U[]; } +>function (e) { // should not error return e.clientWidth;} : (this: undefined, e: HTMLElement) => number >e : HTMLElement return e.clientWidth; diff --git a/tests/baselines/reference/implementArrayInterface.errors.txt b/tests/baselines/reference/implementArrayInterface.errors.txt index 08c438ebaf3..139bb42105d 100644 --- a/tests/baselines/reference/implementArrayInterface.errors.txt +++ b/tests/baselines/reference/implementArrayInterface.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/implementArrayInterface.ts(1,15): error TS2420: Class 'MyArray' incorrectly implements interface 'T[]'. Types of property 'map' are incompatible. - Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '{ (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; }'. + Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '{ (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; }'. Type 'any[]' is not assignable to type '[any, any, any, any, any]'. Property '0' is missing in type 'any[]'. @@ -10,7 +10,7 @@ tests/cases/compiler/implementArrayInterface.ts(1,15): error TS2420: Class 'MyAr ~~~~~~~ !!! error TS2420: Class 'MyArray' incorrectly implements interface 'T[]'. !!! error TS2420: Types of property 'map' are incompatible. -!!! error TS2420: Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '{ (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; }'. +!!! error TS2420: Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '{ (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; }'. !!! error TS2420: Type 'any[]' is not assignable to type '[any, any, any, any, any]'. !!! error TS2420: Property '0' is missing in type 'any[]'. toString(): string; diff --git a/tests/baselines/reference/inferenceLimit.symbols b/tests/baselines/reference/inferenceLimit.symbols index 488838548ad..e471856e448 100644 --- a/tests/baselines/reference/inferenceLimit.symbols +++ b/tests/baselines/reference/inferenceLimit.symbols @@ -64,9 +64,9 @@ export class BrokenClass { >Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->result.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>result.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >result : Symbol(result, Decl(file1.ts, 10, 7)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7)) .then((orders: Array) => { diff --git a/tests/baselines/reference/inferenceLimit.types b/tests/baselines/reference/inferenceLimit.types index bf917e18e93..9f2f11d988f 100644 --- a/tests/baselines/reference/inferenceLimit.types +++ b/tests/baselines/reference/inferenceLimit.types @@ -84,9 +84,9 @@ export class BrokenClass { >Promise : PromiseConstructor >all : { (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; (values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; (values: (T | PromiseLike)[]): Promise; (values: Iterable>): Promise; } >result.map(populateItems) : Promise<{}>[] ->result.map : { (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): U[]; } +>result.map : { (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): U[]; (callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): U[]; } >result : MyModule.MyModel[] ->map : { (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): U[]; } +>map : { (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): U[]; (callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): U[]; } >populateItems : (order: any) => Promise<{}> .then((orders: Array) => { diff --git a/tests/baselines/reference/inferentialTypingWithFunctionType2.symbols b/tests/baselines/reference/inferentialTypingWithFunctionType2.symbols index 56d2c2dc87f..fe60a8c1581 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionType2.symbols +++ b/tests/baselines/reference/inferentialTypingWithFunctionType2.symbols @@ -11,7 +11,7 @@ function identity(a: A): A { } var x = [1, 2, 3].map(identity)[0]; >x : Symbol(x, Decl(inferentialTypingWithFunctionType2.ts, 3, 3)) ->[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >identity : Symbol(identity, Decl(inferentialTypingWithFunctionType2.ts, 0, 0)) diff --git a/tests/baselines/reference/inferentialTypingWithFunctionType2.types b/tests/baselines/reference/inferentialTypingWithFunctionType2.types index b9208409fe0..55caace2c2c 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionType2.types +++ b/tests/baselines/reference/inferentialTypingWithFunctionType2.types @@ -13,12 +13,12 @@ var x = [1, 2, 3].map(identity)[0]; >x : number >[1, 2, 3].map(identity)[0] : number >[1, 2, 3].map(identity) : number[] ->[1, 2, 3].map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>[1, 2, 3].map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >[1, 2, 3] : number[] >1 : 1 >2 : 2 >3 : 3 ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >identity : (a: A) => A >0 : 0 diff --git a/tests/baselines/reference/keyofAndIndexedAccess.symbols b/tests/baselines/reference/keyofAndIndexedAccess.symbols index f6425b5ed0e..d5c4660d474 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess.symbols @@ -454,9 +454,9 @@ function pluck(array: T[], key: K) { >K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 132, 17)) return array.map(x => x[key]); ->array.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>array.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >array : Symbol(array, Decl(keyofAndIndexedAccess.ts, 132, 37)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 133, 21)) >x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 133, 21)) >key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 132, 48)) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 86469efc284..66605b41b75 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -523,10 +523,10 @@ function pluck(array: T[], key: K) { return array.map(x => x[key]); >array.map(x => x[key]) : T[K][] ->array.map : { (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; } +>array.map : { (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } >array : T[] ->map : { (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; } ->x => x[key] : (x: T) => T[K] +>map : { (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } +>x => x[key] : (this: undefined, x: T) => T[K] >x : T >x[key] : T[K] >x : T diff --git a/tests/baselines/reference/mapOnTupleTypes01.symbols b/tests/baselines/reference/mapOnTupleTypes01.symbols index 1dbfca4a4c3..0733b1d5b02 100644 --- a/tests/baselines/reference/mapOnTupleTypes01.symbols +++ b/tests/baselines/reference/mapOnTupleTypes01.symbols @@ -2,8 +2,8 @@ export let mapOnLooseArrayLiteral = [1, 2, 3, 4].map(n => n * n); >mapOnLooseArrayLiteral : Symbol(mapOnLooseArrayLiteral, Decl(mapOnTupleTypes01.ts, 1, 10)) ->[1, 2, 3, 4].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1, 2, 3, 4].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 1, 53)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 1, 53)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 1, 53)) @@ -15,9 +15,9 @@ let numTuple: [number] = [1]; export let a = numTuple.map(x => x * x); >a : Symbol(a, Decl(mapOnTupleTypes01.ts, 6, 10)) ->numTuple.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numTuple.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numTuple : Symbol(numTuple, Decl(mapOnTupleTypes01.ts, 5, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 6, 28)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 6, 28)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 6, 28)) @@ -35,18 +35,18 @@ let numStr: [number, string] = [ 100, "hello"]; export let b = numNum.map(n => n * n); >b : Symbol(b, Decl(mapOnTupleTypes01.ts, 14, 10)) ->numNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNum : Symbol(numNum, Decl(mapOnTupleTypes01.ts, 10, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 14, 26)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 14, 26)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 14, 26)) export let c = strStr.map(s => s.charCodeAt(0)); >c : Symbol(c, Decl(mapOnTupleTypes01.ts, 15, 10)) ->strStr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>strStr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >strStr : Symbol(strStr, Decl(mapOnTupleTypes01.ts, 11, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(mapOnTupleTypes01.ts, 15, 26)) >s.charCodeAt : Symbol(String.charCodeAt, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(mapOnTupleTypes01.ts, 15, 26)) @@ -54,9 +54,9 @@ export let c = strStr.map(s => s.charCodeAt(0)); export let d = numStr.map(x => x); >d : Symbol(d, Decl(mapOnTupleTypes01.ts, 16, 10)) ->numStr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numStr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numStr : Symbol(numStr, Decl(mapOnTupleTypes01.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 16, 26)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 16, 26)) @@ -67,9 +67,9 @@ let numNumNum: [number, number, number] = [1, 2, 3]; export let e = numNumNum.map(n => n * n); >e : Symbol(e, Decl(mapOnTupleTypes01.ts, 22, 10)) ->numNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNumNum : Symbol(numNumNum, Decl(mapOnTupleTypes01.ts, 20, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 22, 29)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 22, 29)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 22, 29)) @@ -81,9 +81,9 @@ let numNumNumNum: [number, number, number, number] = [1, 2, 3, 4]; export let f = numNumNumNum.map(n => n * n); >f : Symbol(f, Decl(mapOnTupleTypes01.ts, 28, 10)) ->numNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNumNumNum : Symbol(numNumNumNum, Decl(mapOnTupleTypes01.ts, 26, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 28, 32)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 28, 32)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 28, 32)) @@ -95,9 +95,9 @@ let numNumNumNumNum: [number, number, number, number, number] = [1, 2, 3, 4, 5]; export let g = numNumNumNumNum.map(n => n * n); >g : Symbol(g, Decl(mapOnTupleTypes01.ts, 34, 10)) ->numNumNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNumNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNumNumNumNum : Symbol(numNumNumNumNum, Decl(mapOnTupleTypes01.ts, 32, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 34, 35)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 34, 35)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 34, 35)) @@ -110,9 +110,9 @@ let numNumNumNumNumNum: [number, number, number, number, number, number] = [1, 2 export let h = numNumNumNumNum.map(n => n * n); >h : Symbol(h, Decl(mapOnTupleTypes01.ts, 41, 10)) ->numNumNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNumNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNumNumNumNum : Symbol(numNumNumNumNum, Decl(mapOnTupleTypes01.ts, 32, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 41, 35)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 41, 35)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 41, 35)) diff --git a/tests/baselines/reference/mapOnTupleTypes01.types b/tests/baselines/reference/mapOnTupleTypes01.types index 0a01ecfa380..b8230d3fdf5 100644 --- a/tests/baselines/reference/mapOnTupleTypes01.types +++ b/tests/baselines/reference/mapOnTupleTypes01.types @@ -3,14 +3,14 @@ export let mapOnLooseArrayLiteral = [1, 2, 3, 4].map(n => n * n); >mapOnLooseArrayLiteral : number[] >[1, 2, 3, 4].map(n => n * n) : number[] ->[1, 2, 3, 4].map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>[1, 2, 3, 4].map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >[1, 2, 3, 4] : number[] >1 : 1 >2 : 2 >3 : 3 >4 : 4 ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -26,10 +26,10 @@ let numTuple: [number] = [1]; export let a = numTuple.map(x => x * x); >a : number[] >numTuple.map(x => x * x) : number[] ->numTuple.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numTuple.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numTuple : [number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->x => x * x : (x: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>x => x * x : (this: undefined, x: number) => number >x : number >x * x : number >x : number @@ -58,10 +58,10 @@ let numStr: [number, string] = [ 100, "hello"]; export let b = numNum.map(n => n * n); >b : [number, number] >numNum.map(n => n * n) : [number, number] ->numNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNum : [number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -70,10 +70,10 @@ export let b = numNum.map(n => n * n); export let c = strStr.map(s => s.charCodeAt(0)); >c : [number, number] >strStr.map(s => s.charCodeAt(0)) : [number, number] ->strStr.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>strStr.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >strStr : [string, string] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->s => s.charCodeAt(0) : (s: string) => number +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>s => s.charCodeAt(0) : (this: undefined, s: string) => number >s : string >s.charCodeAt(0) : number >s.charCodeAt : (index: number) => number @@ -84,10 +84,10 @@ export let c = strStr.map(s => s.charCodeAt(0)); export let d = numStr.map(x => x); >d : [string | number, string | number] >numStr.map(x => x) : [string | number, string | number] ->numStr.map : { (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U]; (this: [string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): U[]; } +>numStr.map : { (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U]; (this: [string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U]; (this: [string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U]; (this: [string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): U[]; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): U[]; } >numStr : [number, string] ->map : { (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U]; (this: [string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): U[]; } ->x => x : (x: string | number) => string | number +>map : { (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U]; (this: [string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U]; (this: [string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U]; (this: [string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): U[]; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): U[]; } +>x => x : (this: undefined, x: string | number) => string | number >x : string | number >x : string | number @@ -103,10 +103,10 @@ let numNumNum: [number, number, number] = [1, 2, 3]; export let e = numNumNum.map(n => n * n); >e : [number, number, number] >numNumNum.map(n => n * n) : [number, number, number] ->numNumNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNumNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNumNum : [number, number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -125,10 +125,10 @@ let numNumNumNum: [number, number, number, number] = [1, 2, 3, 4]; export let f = numNumNumNum.map(n => n * n); >f : [number, number, number, number] >numNumNumNum.map(n => n * n) : [number, number, number, number] ->numNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNumNumNum : [number, number, number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -148,10 +148,10 @@ let numNumNumNumNum: [number, number, number, number, number] = [1, 2, 3, 4, 5]; export let g = numNumNumNumNum.map(n => n * n); >g : [number, number, number, number, number] >numNumNumNumNum.map(n => n * n) : [number, number, number, number, number] ->numNumNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNumNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNumNumNumNum : [number, number, number, number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -173,10 +173,10 @@ let numNumNumNumNumNum: [number, number, number, number, number, number] = [1, 2 export let h = numNumNumNumNum.map(n => n * n); >h : [number, number, number, number, number] >numNumNumNumNum.map(n => n * n) : [number, number, number, number, number] ->numNumNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNumNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNumNumNumNum : [number, number, number, number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number diff --git a/tests/baselines/reference/mapOnTupleTypes02.symbols b/tests/baselines/reference/mapOnTupleTypes02.symbols index da27a13d4f6..6453caace91 100644 --- a/tests/baselines/reference/mapOnTupleTypes02.symbols +++ b/tests/baselines/reference/mapOnTupleTypes02.symbols @@ -9,9 +9,9 @@ export function increment(point: Point) { >Point : Symbol(Point, Decl(mapOnTupleTypes02.ts, 0, 0)) return point.map(d => d + 1); ->point.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>point.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >point : Symbol(point, Decl(mapOnTupleTypes02.ts, 3, 26)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >d : Symbol(d, Decl(mapOnTupleTypes02.ts, 4, 19)) >d : Symbol(d, Decl(mapOnTupleTypes02.ts, 4, 19)) } diff --git a/tests/baselines/reference/mapOnTupleTypes02.types b/tests/baselines/reference/mapOnTupleTypes02.types index 3803e3c319e..5ec555ebf17 100644 --- a/tests/baselines/reference/mapOnTupleTypes02.types +++ b/tests/baselines/reference/mapOnTupleTypes02.types @@ -10,10 +10,10 @@ export function increment(point: Point) { return point.map(d => d + 1); >point.map(d => d + 1) : [number, number] ->point.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>point.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >point : [number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->d => d + 1 : (d: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>d => d + 1 : (this: undefined, d: number) => number >d : number >d + 1 : number >d : number diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols index 62473581abe..ccee4a59a70 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types index b259e30172d..532ef5511fa 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols index ccb78b1c367..97c6852b503 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types index 4fa4c085bca..304b9411bff 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols index 0bbffee6c86..5aae1a6cb2f 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types index 25cd47601e0..28ceac3ac91 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols index d3d3e3d1ed6..568c87d928f 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols +++ b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types index 5b96ce987bc..c1005cadca6 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols index ce03d4cfc59..90a88d4fbaa 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_UsingES5LibAndES6ArrayLib.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types index a097b116186..b7ab82ffb7d 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols index 0ed5ec38513..83ae1ac5f08 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols @@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.ts, 1, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types index 6accc7e7905..3515b6dc55d 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/nestedSelf.symbols b/tests/baselines/reference/nestedSelf.symbols index b9a9e91d36d..6fa6bb1b59f 100644 --- a/tests/baselines/reference/nestedSelf.symbols +++ b/tests/baselines/reference/nestedSelf.symbols @@ -10,8 +10,8 @@ module M { public foo() { [1,2,3].map((x) => { return this.n * x; })} >foo : Symbol(C.foo, Decl(nestedSelf.ts, 2, 17)) ->[1,2,3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1,2,3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(nestedSelf.ts, 3, 31)) >this.n : Symbol(C.n, Decl(nestedSelf.ts, 1, 17)) >this : Symbol(C, Decl(nestedSelf.ts, 0, 10)) diff --git a/tests/baselines/reference/nestedSelf.types b/tests/baselines/reference/nestedSelf.types index 1ec95a8d24a..176e0dc28d3 100644 --- a/tests/baselines/reference/nestedSelf.types +++ b/tests/baselines/reference/nestedSelf.types @@ -12,13 +12,13 @@ module M { public foo() { [1,2,3].map((x) => { return this.n * x; })} >foo : () => void >[1,2,3].map((x) => { return this.n * x; }) : number[] ->[1,2,3].map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>[1,2,3].map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >[1,2,3] : number[] >1 : 1 >2 : 2 >3 : 3 ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->(x) => { return this.n * x; } : (x: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>(x) => { return this.n * x; } : (this: undefined, x: number) => number >x : number >this.n * x : number >this.n : number diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols index 6cee1604cf0..e2e776cf72e 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols @@ -4,9 +4,9 @@ var regexMatchList = ['', '']; >regexMatchList : Symbol(regexMatchList, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 1, 3)) regexMatchList.forEach(match => ''.replace(match, '')); ->regexMatchList.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>regexMatchList.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >regexMatchList : Symbol(regexMatchList, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 1, 3)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) >''.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types index 928185a0953..d7cb482a51c 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types @@ -8,10 +8,10 @@ var regexMatchList = ['', '']; regexMatchList.forEach(match => ''.replace(match, '')); >regexMatchList.forEach(match => ''.replace(match, '')) : void ->regexMatchList.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>regexMatchList.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } >regexMatchList : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->match => ''.replace(match, '') : (match: string) => string +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>match => ''.replace(match, '') : (this: undefined, match: string) => string >match : string >''.replace(match, '') : string >''.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } diff --git a/tests/baselines/reference/objectRestForOf.symbols b/tests/baselines/reference/objectRestForOf.symbols index f3786fed55f..d10b0de4d0e 100644 --- a/tests/baselines/reference/objectRestForOf.symbols +++ b/tests/baselines/reference/objectRestForOf.symbols @@ -32,9 +32,9 @@ for ({ x: xx, ...rrestOff } of array ) { } for (const norest of array.map(a => ({ ...a, x: 'a string' }))) { >norest : Symbol(norest, Decl(objectRestForOf.ts, 9, 10)) ->array.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>array.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >array : Symbol(array, Decl(objectRestForOf.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >a : Symbol(a, Decl(objectRestForOf.ts, 9, 31)) >a : Symbol(a, Decl(objectRestForOf.ts, 9, 31)) >x : Symbol(x, Decl(objectRestForOf.ts, 9, 44)) diff --git a/tests/baselines/reference/objectRestForOf.types b/tests/baselines/reference/objectRestForOf.types index 2fde7566c74..b7d1d1ac7be 100644 --- a/tests/baselines/reference/objectRestForOf.types +++ b/tests/baselines/reference/objectRestForOf.types @@ -36,10 +36,10 @@ for ({ x: xx, ...rrestOff } of array ) { for (const norest of array.map(a => ({ ...a, x: 'a string' }))) { >norest : { x: string; y: string; } >array.map(a => ({ ...a, x: 'a string' })) : { x: string; y: string; }[] ->array.map : { (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): U[]; } +>array.map : { (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): U[]; (callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): U[]; } >array : { x: number; y: string; }[] ->map : { (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): U[]; } ->a => ({ ...a, x: 'a string' }) : (a: { x: number; y: string; }) => { x: string; y: string; } +>map : { (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): U[]; (callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): U[]; } +>a => ({ ...a, x: 'a string' }) : (this: undefined, a: { x: number; y: string; }) => { x: string; y: string; } >a : { x: number; y: string; } >({ ...a, x: 'a string' }) : { x: string; y: string; } >{ ...a, x: 'a string' } : { x: string; y: string; } diff --git a/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.symbols b/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.symbols index 23a1df25653..edb2c362fc2 100644 --- a/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.symbols +++ b/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.symbols @@ -1,9 +1,9 @@ === tests/cases/compiler/simpleArrowFunctionParameterReferencedInObjectLiteral1.ts === [].map(() => [].map(p => ({ X: p }))); ->[].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->[].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >p : Symbol(p, Decl(simpleArrowFunctionParameterReferencedInObjectLiteral1.ts, 0, 20)) >X : Symbol(X, Decl(simpleArrowFunctionParameterReferencedInObjectLiteral1.ts, 0, 27)) >p : Symbol(p, Decl(simpleArrowFunctionParameterReferencedInObjectLiteral1.ts, 0, 20)) diff --git a/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.types b/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.types index ff1640909d9..ad683ef2e15 100644 --- a/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.types +++ b/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.types @@ -1,15 +1,15 @@ === tests/cases/compiler/simpleArrowFunctionParameterReferencedInObjectLiteral1.ts === [].map(() => [].map(p => ({ X: p }))); >[].map(() => [].map(p => ({ X: p }))) : { X: any; }[][] ->[].map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>[].map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >[] : undefined[] ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >() => [].map(p => ({ X: p })) : () => { X: any; }[] >[].map(p => ({ X: p })) : { X: any; }[] ->[].map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>[].map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >[] : undefined[] ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } ->p => ({ X: p }) : (p: any) => { X: any; } +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>p => ({ X: p }) : (this: undefined, p: any) => { X: any; } >p : any >({ X: p }) : { X: any; } >{ X: p } : { X: any; } diff --git a/tests/baselines/reference/specializationsShouldNotAffectEachOther.symbols b/tests/baselines/reference/specializationsShouldNotAffectEachOther.symbols index 7d5a6d979b3..8c8b372bbc8 100644 --- a/tests/baselines/reference/specializationsShouldNotAffectEachOther.symbols +++ b/tests/baselines/reference/specializationsShouldNotAffectEachOther.symbols @@ -23,9 +23,9 @@ function foo() { >series2 : Symbol(series2, Decl(specializationsShouldNotAffectEachOther.ts, 12, 7)) series2.map(seriesExtent); ->series2.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>series2.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >series2 : Symbol(series2, Decl(specializationsShouldNotAffectEachOther.ts, 12, 7)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >seriesExtent : Symbol(seriesExtent, Decl(specializationsShouldNotAffectEachOther.ts, 10, 7)) return null; @@ -34,11 +34,11 @@ function foo() { var keyExtent2: any[] = series.data.map(function (d: string) { return d; }); >keyExtent2 : Symbol(keyExtent2, Decl(specializationsShouldNotAffectEachOther.ts, 19, 3)) ->series.data.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>series.data.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >series.data : Symbol(Series.data, Decl(specializationsShouldNotAffectEachOther.ts, 1, 19)) >series : Symbol(series, Decl(specializationsShouldNotAffectEachOther.ts, 5, 3)) >data : Symbol(Series.data, Decl(specializationsShouldNotAffectEachOther.ts, 1, 19)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >d : Symbol(d, Decl(specializationsShouldNotAffectEachOther.ts, 19, 50)) >d : Symbol(d, Decl(specializationsShouldNotAffectEachOther.ts, 19, 50)) diff --git a/tests/baselines/reference/specializationsShouldNotAffectEachOther.types b/tests/baselines/reference/specializationsShouldNotAffectEachOther.types index aa14eca0508..d9c9b7baa20 100644 --- a/tests/baselines/reference/specializationsShouldNotAffectEachOther.types +++ b/tests/baselines/reference/specializationsShouldNotAffectEachOther.types @@ -26,9 +26,9 @@ function foo() { series2.map(seriesExtent); >series2.map(seriesExtent) : any[] ->series2.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>series2.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >series2 : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >seriesExtent : (series: any) => any return null; @@ -39,12 +39,12 @@ function foo() { var keyExtent2: any[] = series.data.map(function (d: string) { return d; }); >keyExtent2 : any[] >series.data.map(function (d: string) { return d; }) : string[] ->series.data.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>series.data.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >series.data : string[] >series : Series >data : string[] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->function (d: string) { return d; } : (d: string) => string +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>function (d: string) { return d; } : (this: undefined, d: string) => string >d : string >d : string diff --git a/tests/baselines/reference/targetTypeArgs.symbols b/tests/baselines/reference/targetTypeArgs.symbols index b0d825ddd50..d7c40a6a609 100644 --- a/tests/baselines/reference/targetTypeArgs.symbols +++ b/tests/baselines/reference/targetTypeArgs.symbols @@ -14,44 +14,44 @@ foo(function(x) { x }); >x : Symbol(x, Decl(targetTypeArgs.ts, 4, 13)) [1].forEach(function(v,i,a) { v }); ->[1].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>[1].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 6, 21)) >i : Symbol(i, Decl(targetTypeArgs.ts, 6, 23)) >a : Symbol(a, Decl(targetTypeArgs.ts, 6, 25)) >v : Symbol(v, Decl(targetTypeArgs.ts, 6, 21)) ["hello"].every(function(v,i,a) {return true;}); ->["hello"].every : Symbol(Array.every, Decl(lib.d.ts, --, --)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>["hello"].every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 7, 25)) >i : Symbol(i, Decl(targetTypeArgs.ts, 7, 27)) >a : Symbol(a, Decl(targetTypeArgs.ts, 7, 29)) [1].every(function(v,i,a) {return true;}); ->[1].every : Symbol(Array.every, Decl(lib.d.ts, --, --)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>[1].every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 8, 19)) >i : Symbol(i, Decl(targetTypeArgs.ts, 8, 21)) >a : Symbol(a, Decl(targetTypeArgs.ts, 8, 23)) [1].every(function(v,i,a) {return true;}); ->[1].every : Symbol(Array.every, Decl(lib.d.ts, --, --)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>[1].every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 9, 19)) >i : Symbol(i, Decl(targetTypeArgs.ts, 9, 21)) >a : Symbol(a, Decl(targetTypeArgs.ts, 9, 23)) ["s"].every(function(v,i,a) {return true;}); ->["s"].every : Symbol(Array.every, Decl(lib.d.ts, --, --)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>["s"].every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 10, 21)) >i : Symbol(i, Decl(targetTypeArgs.ts, 10, 23)) >a : Symbol(a, Decl(targetTypeArgs.ts, 10, 25)) ["s"].forEach(function(v,i,a) { v }); ->["s"].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>["s"].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 11, 23)) >i : Symbol(i, Decl(targetTypeArgs.ts, 11, 25)) >a : Symbol(a, Decl(targetTypeArgs.ts, 11, 27)) diff --git a/tests/baselines/reference/targetTypeArgs.types b/tests/baselines/reference/targetTypeArgs.types index 84985316aa2..e1bcb00ba15 100644 --- a/tests/baselines/reference/targetTypeArgs.types +++ b/tests/baselines/reference/targetTypeArgs.types @@ -19,11 +19,11 @@ foo(function(x) { x }); [1].forEach(function(v,i,a) { v }); >[1].forEach(function(v,i,a) { v }) : void ->[1].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>[1].forEach : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } >[1] : number[] >1 : 1 ->forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void ->function(v,i,a) { v } : (v: number, i: number, a: number[]) => void +>forEach : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } +>function(v,i,a) { v } : (this: undefined, v: number, i: number, a: number[]) => void >v : number >i : number >a : number[] @@ -31,11 +31,11 @@ foo(function(x) { x }); ["hello"].every(function(v,i,a) {return true;}); >["hello"].every(function(v,i,a) {return true;}) : boolean ->["hello"].every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean +>["hello"].every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } >["hello"] : string[] >"hello" : "hello" ->every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true +>every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function(v,i,a) {return true;} : (this: undefined, v: string, i: number, a: string[]) => true >v : string >i : number >a : string[] @@ -43,11 +43,11 @@ foo(function(x) { x }); [1].every(function(v,i,a) {return true;}); >[1].every(function(v,i,a) {return true;}) : boolean ->[1].every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>[1].every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } >[1] : number[] >1 : 1 ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true +>every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } +>function(v,i,a) {return true;} : (this: undefined, v: number, i: number, a: number[]) => true >v : number >i : number >a : number[] @@ -55,11 +55,11 @@ foo(function(x) { x }); [1].every(function(v,i,a) {return true;}); >[1].every(function(v,i,a) {return true;}) : boolean ->[1].every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>[1].every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } >[1] : number[] >1 : 1 ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true +>every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } +>function(v,i,a) {return true;} : (this: undefined, v: number, i: number, a: number[]) => true >v : number >i : number >a : number[] @@ -67,11 +67,11 @@ foo(function(x) { x }); ["s"].every(function(v,i,a) {return true;}); >["s"].every(function(v,i,a) {return true;}) : boolean ->["s"].every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean +>["s"].every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } >["s"] : string[] >"s" : "s" ->every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true +>every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function(v,i,a) {return true;} : (this: undefined, v: string, i: number, a: string[]) => true >v : string >i : number >a : string[] @@ -79,11 +79,11 @@ foo(function(x) { x }); ["s"].forEach(function(v,i,a) { v }); >["s"].forEach(function(v,i,a) { v }) : void ->["s"].forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>["s"].forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } >["s"] : string[] >"s" : "s" ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function(v,i,a) { v } : (v: string, i: number, a: string[]) => void +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function(v,i,a) { v } : (this: undefined, v: string, i: number, a: string[]) => void >v : string >i : number >a : string[] diff --git a/tests/baselines/reference/targetTypeObjectLiteralToAny.symbols b/tests/baselines/reference/targetTypeObjectLiteralToAny.symbols index 6df8d8ac2ad..d7903e3328a 100644 --- a/tests/baselines/reference/targetTypeObjectLiteralToAny.symbols +++ b/tests/baselines/reference/targetTypeObjectLiteralToAny.symbols @@ -9,9 +9,9 @@ function suggest(){ >result : Symbol(result, Decl(targetTypeObjectLiteralToAny.ts, 2, 4)) TypeScriptKeywords.forEach(function(keyword) { ->TypeScriptKeywords.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>TypeScriptKeywords.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >TypeScriptKeywords : Symbol(TypeScriptKeywords, Decl(targetTypeObjectLiteralToAny.ts, 1, 4)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >keyword : Symbol(keyword, Decl(targetTypeObjectLiteralToAny.ts, 4, 37)) result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any diff --git a/tests/baselines/reference/targetTypeObjectLiteralToAny.types b/tests/baselines/reference/targetTypeObjectLiteralToAny.types index 1dd81b33603..1364a5b2a23 100644 --- a/tests/baselines/reference/targetTypeObjectLiteralToAny.types +++ b/tests/baselines/reference/targetTypeObjectLiteralToAny.types @@ -10,10 +10,10 @@ function suggest(){ TypeScriptKeywords.forEach(function(keyword) { >TypeScriptKeywords.forEach(function(keyword) { result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any }) : void ->TypeScriptKeywords.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>TypeScriptKeywords.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } >TypeScriptKeywords : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function(keyword) { result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any } : (keyword: string) => void +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function(keyword) { result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any } : (this: undefined, keyword: string) => void >keyword : string result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any diff --git a/tests/baselines/reference/tsxSpreadChildren.symbols b/tests/baselines/reference/tsxSpreadChildren.symbols index b2631c70fd9..2556b7c61b6 100644 --- a/tests/baselines/reference/tsxSpreadChildren.symbols +++ b/tests/baselines/reference/tsxSpreadChildren.symbols @@ -59,9 +59,9 @@ function TodoList({ todos }: TodoListProps) { >div : Symbol(JSX.IntrinsicElements, Decl(tsxSpreadChildren.tsx, 2, 22)) {...todos.map(todo => )} ->todos.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>todos.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >todos : Symbol(todos, Decl(tsxSpreadChildren.tsx, 19, 19)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >todo : Symbol(todo, Decl(tsxSpreadChildren.tsx, 21, 22)) >Todo : Symbol(Todo, Decl(tsxSpreadChildren.tsx, 15, 1)) >key : Symbol(key, Decl(tsxSpreadChildren.tsx, 21, 35)) diff --git a/tests/baselines/reference/tsxSpreadChildren.types b/tests/baselines/reference/tsxSpreadChildren.types index 1317499ff45..9ab9d7093d4 100644 --- a/tests/baselines/reference/tsxSpreadChildren.types +++ b/tests/baselines/reference/tsxSpreadChildren.types @@ -64,10 +64,10 @@ function TodoList({ todos }: TodoListProps) { {...todos.map(todo => )} >todos.map(todo => ) : JSX.Element[] ->todos.map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): U[]; } +>todos.map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): U[]; (callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): U[]; } >todos : TodoProp[] ->map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): U[]; } ->todo => : (todo: TodoProp) => JSX.Element +>map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): U[]; (callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): U[]; } +>todo => : (this: undefined, todo: TodoProp) => JSX.Element >todo : TodoProp > : JSX.Element >Todo : (prop: { key: number; todo: string; }) => JSX.Element diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols index 766c75e2c13..d294a9c28cf 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols @@ -15,9 +15,9 @@ var nodes: TreeNode[]; >TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) nodes.map(n => n.name); ->nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) >n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types index 045b5e65da3..21332704326 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types @@ -16,10 +16,10 @@ var nodes: TreeNode[]; nodes.map(n => n.name); >nodes.map(n => n.name) : string[] ->nodes.map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): U[]; } +>nodes.map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): U[]; (callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): U[]; } >nodes : TreeNode[] ->map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): U[]; } ->n => n.name : (n: TreeNode) => string +>map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): U[]; (callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): U[]; } +>n => n.name : (this: undefined, n: TreeNode) => string >n : TreeNode >n.name : string >n : TreeNode diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols index 62e2b398827..3761994619c 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols @@ -26,9 +26,9 @@ var nodes: TreeNodeMiddleman[]; >TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1)) nodes.map(n => n.name); ->nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) >n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types index a75a997eb78..6cb4b81e0ce 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types @@ -27,10 +27,10 @@ var nodes: TreeNodeMiddleman[]; nodes.map(n => n.name); >nodes.map(n => n.name) : string[] ->nodes.map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): U[]; } +>nodes.map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): U[]; (callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): U[]; } >nodes : TreeNodeMiddleman[] ->map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): U[]; } ->n => n.name : (n: TreeNodeMiddleman) => string +>map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): U[]; (callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): U[]; } +>n => n.name : (this: undefined, n: TreeNodeMiddleman) => string >n : TreeNodeMiddleman >n.name : string >n : TreeNodeMiddleman diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index 2d45fb7e5c1..ca7812bbcc8 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -242,65 +242,65 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -458,73 +458,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) @@ -546,81 +546,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index 444d6a74e43..24924a5810e 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -274,9 +274,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : number[] typedArrays[1] = Uint8Array.from(obj); @@ -285,9 +285,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : number[] typedArrays[2] = Int16Array.from(obj); @@ -296,9 +296,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : number[] typedArrays[3] = Uint16Array.from(obj); @@ -307,9 +307,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : number[] typedArrays[4] = Int32Array.from(obj); @@ -318,9 +318,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : number[] typedArrays[5] = Uint32Array.from(obj); @@ -329,9 +329,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : number[] typedArrays[6] = Float32Array.from(obj); @@ -340,9 +340,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : number[] typedArrays[7] = Float64Array.from(obj); @@ -351,9 +351,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : number[] typedArrays[8] = Uint8ClampedArray.from(obj); @@ -362,9 +362,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : number[] return typedArrays; @@ -386,9 +386,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : ArrayLike typedArrays[1] = Uint8Array.from(obj); @@ -397,9 +397,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : ArrayLike typedArrays[2] = Int16Array.from(obj); @@ -408,9 +408,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : ArrayLike typedArrays[3] = Uint16Array.from(obj); @@ -419,9 +419,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : ArrayLike typedArrays[4] = Int32Array.from(obj); @@ -430,9 +430,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : ArrayLike typedArrays[5] = Uint32Array.from(obj); @@ -441,9 +441,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : ArrayLike typedArrays[6] = Float32Array.from(obj); @@ -452,9 +452,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : ArrayLike typedArrays[7] = Float64Array.from(obj); @@ -463,9 +463,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : ArrayLike typedArrays[8] = Uint8ClampedArray.from(obj); @@ -474,9 +474,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : ArrayLike return typedArrays; @@ -758,9 +758,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -770,9 +770,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -782,9 +782,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -794,9 +794,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -806,9 +806,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -818,9 +818,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -830,9 +830,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -842,9 +842,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -854,9 +854,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -883,9 +883,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn, thisArg) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -896,9 +896,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn, thisArg) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -909,9 +909,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn, thisArg) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -922,9 +922,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn, thisArg) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -935,9 +935,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn, thisArg) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -948,9 +948,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn, thisArg) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -961,9 +961,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn, thisArg) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -974,9 +974,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn, thisArg) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -987,9 +987,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} From 3f980bead0bac4865fd64d14e37c158e118dc0af Mon Sep 17 00:00:00 2001 From: DLehenbauer Date: Fri, 10 Mar 2017 07:10:58 -0800 Subject: [PATCH 132/167] Remove vestiges of WScript support (Issue #14414) --- Jakefile.js | 8 +- src/compiler/diagnosticMessages.json | 4 - src/compiler/program.ts | 7 +- src/compiler/sys.ts | 156 --------------------------- src/harness/harness.ts | 100 ++--------------- src/tsconfig-base.json | 4 +- 6 files changed, 13 insertions(+), 266 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 595875dfc32..9f075f7c056 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -333,7 +333,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts options += " --lib " + opts.lib } else { - options += " --lib es5,scripthost" + options += " --lib es5" } options += " --noUnusedLocals --noUnusedParameters"; @@ -587,13 +587,13 @@ var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: true, lib: "es6" }); var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js"); -compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6,scripthost" }); +compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" }); var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js"); compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" }); var serverFile = path.join(builtLocalDirectory, "tsserver.js"); -compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6,scripthost" }); +compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); compileFile( @@ -717,7 +717,7 @@ compileFile( /*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources), /*prefixes*/[], /*useBuiltCompiler:*/ true, - /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6,scripthost" }); + /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" }); var internalTests = "internal/"; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 318f06ceeaa..919158645a4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2413,10 +2413,6 @@ "category": "Error", "code": 5012 }, - "Unsupported file encoding.": { - "category": "Error", - "code": 5013 - }, "Failed to parse file '{0}': {1}.": { "category": "Error", "code": 5014 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index abb8b0b2f09..e117761a3a3 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -87,9 +87,6 @@ namespace ts { return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); } - // returned by CScript sys environment - const unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile { let text: string; try { @@ -100,9 +97,7 @@ namespace ts { } catch (e) { if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? createCompilerDiagnostic(Diagnostics.Unsupported_file_encoding).messageText - : e.message); + onError(e.message); } text = ""; } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 2a15df80102..3f585900654 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -74,13 +74,6 @@ namespace ts { return parseInt(version.substring(1, dot)); } - declare class Enumerator { - public atEnd(): boolean; - public moveNext(): boolean; - public item(): any; - constructor(o: any); - } - declare var ChakraHost: { args: string[]; currentDirectory: string; @@ -104,152 +97,6 @@ namespace ts { }; export let sys: System = (function() { - - function getWScriptSystem(): System { - - const fso = new ActiveXObject("Scripting.FileSystemObject"); - const shell = new ActiveXObject("WScript.Shell"); - - const fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2 /*text*/; - - const binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1 /*binary*/; - - const args: string[] = []; - for (let i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - function readFile(fileName: string, encoding?: string): string { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - // Load file and read the first two bytes into a string with no interpretation - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - const bom = fileStream.ReadText(2) || ""; - // Position must be at 0 before encoding can be changed - fileStream.Position = 0; - // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - // ReadText method always strips byte order mark from resulting string - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - - function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void { - fileStream.Open(); - binaryStream.Open(); - try { - // Write characters in UTF-8 encoding - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - // If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM). - // If not, start from position 0, as the BOM will be added automatically when charset==utf8. - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2 /*overwrite*/); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - - function getNames(collection: any): string[] { - const result: string[] = []; - for (const e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - - function getDirectories(path: string): string[] { - const folder = fso.GetFolder(path); - return getNames(folder.subfolders); - } - - function getAccessibleFileSystemEntries(path: string): FileSystemEntries { - try { - const folder = fso.GetFolder(path || "."); - const files = getNames(folder.files); - const directories = getNames(folder.subfolders); - return { files, directories }; - } - catch (e) { - return { files: [], directories: [] }; - } - } - - function readDirectory(path: string, extensions?: string[], excludes?: string[], includes?: string[]): string[] { - return matchFiles(path, extensions, excludes, includes, /*useCaseSensitiveFileNames*/ false, shell.CurrentDirectory, getAccessibleFileSystemEntries); - } - - const wscriptSystem: System = { - args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write(s: string): void { - WScript.StdOut.Write(s); - }, - readFile, - writeFile, - resolvePath(path: string): string { - return fso.GetAbsolutePathName(path); - }, - fileExists(path: string): boolean { - return fso.FileExists(path); - }, - directoryExists(path: string) { - return fso.FolderExists(path); - }, - createDirectory(directoryName: string) { - if (!wscriptSystem.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath() { - return WScript.ScriptFullName; - }, - getCurrentDirectory() { - return shell.CurrentDirectory; - }, - getDirectories, - getEnvironmentVariable(name: string) { - return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings(`%${name}%`); - }, - readDirectory, - exit(exitCode?: number): void { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - return wscriptSystem; - } - function getNodeSystem(): System { const _fs = require("fs"); const _path = require("path"); @@ -646,9 +493,6 @@ namespace ts { if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); } - else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - sys = getWScriptSystem(); - } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { // process and process.nextTick checks if current environment is node-like // process.browser check excludes webpack and browserify diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 23e8106864a..57041a1f2e3 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -34,12 +34,6 @@ var _chai: typeof chai = require("chai"); var assert: typeof _chai.assert = _chai.assert; declare var __dirname: string; // Node-specific var global: NodeJS.Global = Function("return this").call(undefined); -declare namespace NodeJS { - export interface Global { - WScript: typeof WScript; - ActiveXObject: typeof ActiveXObject; - } -} declare var window: {}; declare var XMLHttpRequest: { @@ -60,14 +54,10 @@ namespace Utils { export const enum ExecutionEnvironment { Node, Browser, - CScript } export function getExecutionEnvironment() { - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return ExecutionEnvironment.CScript; - } - else if (typeof window !== "undefined") { + if (typeof window !== "undefined") { return ExecutionEnvironment.Browser; } else { @@ -93,7 +83,6 @@ namespace Utils { export function evalFile(fileContents: string, fileName: string, nodeContext?: any) { const environment = getExecutionEnvironment(); switch (environment) { - case ExecutionEnvironment.CScript: case ExecutionEnvironment.Browser: eval(fileContents); break; @@ -516,83 +505,6 @@ namespace Harness { export const virtualFileSystemRoot = "/"; namespace IOImpl { - declare class Enumerator { - public atEnd(): boolean; - public moveNext(): boolean; - public item(): any; - constructor(o: any); - } - - export namespace CScript { - let fso: any; - if (global.ActiveXObject) { - fso = new global.ActiveXObject("Scripting.FileSystemObject"); - } - else { - fso = {}; - } - - export const args = () => ts.sys.args; - export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); - export const exit = (exitCode: number) => ts.sys.exit(exitCode); - export const resolvePath = (path: string) => ts.sys.resolvePath(path); - export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); - export const newLine = () => harnessNewLine; - export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames; - - export const readFile: typeof IO.readFile = path => ts.sys.readFile(path); - export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content); - export const directoryName: typeof IO.directoryName = fso.GetParentFolderName; - export const getDirectories: typeof IO.getDirectories = dir => ts.sys.getDirectories(dir); - export const directoryExists: typeof IO.directoryExists = fso.FolderExists; - export const fileExists: typeof IO.fileExists = fso.FileExists; - export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; - export const getEnvironmentVariable: typeof IO.getEnvironmentVariable = name => ts.sys.getEnvironmentVariable(name); - export const readDirectory: typeof IO.readDirectory = (path, extension, exclude, include) => ts.sys.readDirectory(path, extension, exclude, include); - - export function createDirectory(path: string) { - if (directoryExists(path)) { - fso.CreateFolder(path); - } - } - - export function deleteFile(path: string) { - if (fileExists(path)) { - fso.DeleteFile(path, true); // true: delete read-only files - } - } - - export let listFiles: typeof IO.listFiles = (path, spec?, options?) => { - options = options || <{ recursive?: boolean; }>{}; - function filesInFolder(folder: any, root: string): string[] { - let paths: string[] = []; - let fc: any; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - const folder: any = fso.GetFolder(path); - - return filesInFolder(folder, path); - }; - } - export namespace Node { declare const require: any; let fs: any, pathModule: any; @@ -840,16 +752,16 @@ namespace Harness { } } - switch (Utils.getExecutionEnvironment()) { - case Utils.ExecutionEnvironment.CScript: - IO = IOImpl.CScript; - break; + const environment = Utils.getExecutionEnvironment(); + switch (environment) { case Utils.ExecutionEnvironment.Node: IO = IOImpl.Node; break; case Utils.ExecutionEnvironment.Browser: IO = IOImpl.Network; break; + default: + throw new Error(`Unknown value '${environment}' for ExecutionEnvironment'.`); } } @@ -873,7 +785,7 @@ namespace Harness { /** Aggregate various writes into a single array of lines. Useful for passing to the * TypeScript compiler to fill with source code or errors. */ - export class WriterAggregator implements ITextWriter { + export class WriterAggregator { public lines: string[] = []; public currentLine = undefined; diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index 078fdcc91e7..caf8e880fad 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "lib": ["es5", "scripthost"], + "lib": ["es5"], "noEmitOnError": true, "noImplicitAny": true, "noImplicitThis": true, @@ -13,4 +13,4 @@ "target": "es5", "types": [] } -} \ No newline at end of file +} From 17cb68cbbf3754342c950990c4705d74bba8b15e Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 10 Mar 2017 10:34:01 -0800 Subject: [PATCH 133/167] send error if obtaining of types-registry package failed (#14573) --- src/server/protocol.ts | 11 +++++++++++ src/server/server.ts | 14 +++++++++++++- src/server/shared.ts | 1 + src/server/types.ts | 8 +++++++- .../typingsInstaller/nodeTypingsInstaller.ts | 14 +++++++++++++- 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index d054867cd1c..d12aa2e0a48 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2127,6 +2127,17 @@ namespace ts.server.protocol { payload: any; } + export type TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; + + export interface TypesInstallerInitializationFailedEvent extends Event { + event: TypesInstallerInitializationFailedEventName; + body: TypesInstallerInitializationFailedEventBody; + } + + export interface TypesInstallerInitializationFailedEventBody { + message: string; + } + export type TypingsInstalledTelemetryEventName = "typingsInstalled"; export interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { diff --git a/src/server/server.ts b/src/server/server.ts index 475e5cdf920..bfd4e422047 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -304,11 +304,23 @@ namespace ts.server { }); } - private handleMessage(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes) { + private handleMessage(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | InitializationFailedResponse) { if (this.logger.hasLevel(LogLevel.verbose)) { this.logger.info(`Received response: ${JSON.stringify(response)}`); } + if (response.kind === EventInitializationFailed) { + if (!this.eventSender) { + return; + } + const body: protocol.TypesInstallerInitializationFailedEventBody = { + message: response.message + } + const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; + this.eventSender.event(body, eventName); + return; + } + if (response.kind === EventBeginInstallTypes) { if (!this.eventSender) { return; diff --git a/src/server/shared.ts b/src/server/shared.ts index 77f66fc5a2d..5d65f8c90e9 100644 --- a/src/server/shared.ts +++ b/src/server/shared.ts @@ -5,6 +5,7 @@ namespace ts.server { export const ActionInvalidate: ActionInvalidate = "action::invalidate"; export const EventBeginInstallTypes: EventBeginInstallTypes = "event::beginInstallTypes"; export const EventEndInstallTypes: EventEndInstallTypes = "event::endInstallTypes"; + export const EventInitializationFailed: EventInitializationFailed = "event::initializationFailed"; export namespace Arguments { export const GlobalCacheLocation = "--globalTypingsCacheLocation"; diff --git a/src/server/types.ts b/src/server/types.ts index 6edf424cbe6..81e1f09639f 100644 --- a/src/server/types.ts +++ b/src/server/types.ts @@ -47,9 +47,15 @@ declare namespace ts.server { export type ActionInvalidate = "action::invalidate"; export type EventBeginInstallTypes = "event::beginInstallTypes"; export type EventEndInstallTypes = "event::endInstallTypes"; + export type EventInitializationFailed = "event::initializationFailed"; export interface TypingInstallerResponse { - readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes; + readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed; + } + + export interface InitializationFailedResponse extends TypingInstallerResponse { + readonly kind: EventInitializationFailed; + readonly message: string; } export interface ProjectResponse extends TypingInstallerResponse { diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index b9d08937467..74497504ba3 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -74,6 +74,8 @@ namespace ts.server.typingsInstaller { private readonly npmPath: string; readonly typesRegistry: Map; + private delayedInitializationError: InitializationFailedResponse; + constructor(globalTypingsCacheLocation: string, throttleLimit: number, log: Log) { super( sys, @@ -99,6 +101,11 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Error updating ${TypesRegistryPackageName} package: ${(e).message}`); } + // store error info to report it later when it is known that server is already listening to events from typings installer + this.delayedInitializationError = { + kind: "event::initializationFailed", + message: (e).message + }; } this.typesRegistry = loadTypesRegistryFile(getTypesRegistryFileLocation(globalTypingsCacheLocation), this.installTypingHost, this.log); @@ -106,6 +113,11 @@ namespace ts.server.typingsInstaller { listen() { process.on("message", (req: DiscoverTypings | CloseProject) => { + if (this.delayedInitializationError) { + // report initializationFailed error + this.sendResponse(this.delayedInitializationError); + this.delayedInitializationError = undefined; + } switch (req.kind) { case "discover": this.install(req); @@ -116,7 +128,7 @@ namespace ts.server.typingsInstaller { }); } - protected sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes) { + protected sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | InitializationFailedResponse) { if (this.log.isEnabled()) { this.log.writeLine(`Sending response: ${JSON.stringify(response)}`); } From 746b7e4798595b518f2c2778a78607045ea9d472 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 10 Mar 2017 10:42:26 -0800 Subject: [PATCH 134/167] Expose `forEachChild` as a method of Node --- src/services/services.ts | 8 ++++++++ src/services/types.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/services/services.ts b/src/services/services.ts index df5330ebaed..0a4733cf98a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -209,6 +209,10 @@ namespace ts { return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile); } + + public forEachChild(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T { + return forEachChild(this, cbNode, cbNodeArray); + } } class TokenOrIdentifierObject implements Node { @@ -282,6 +286,10 @@ namespace ts { public getLastToken(): Node { return undefined; } + + public forEachChild(): T { + return undefined; + } } class SymbolObject implements Symbol { diff --git a/src/services/types.ts b/src/services/types.ts index c7852db6d6e..f67cc6b918f 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -14,6 +14,8 @@ namespace ts { getText(sourceFile?: SourceFile): string; getFirstToken(sourceFile?: SourceFile): Node; getLastToken(sourceFile?: SourceFile): Node; + // See ts.forEachChild for documentation. + forEachChild(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; } export interface Symbol { From 2980231b5ee3c89b70a4d1ff8a465bfbecc5efc3 Mon Sep 17 00:00:00 2001 From: Christophe Vidal Date: Sat, 11 Mar 2017 01:55:50 +0700 Subject: [PATCH 135/167] Updated quick start & handbook links in README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f631439eb0..d21e558360c 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,8 @@ with any additional questions or comments. ## Documentation -* [Quick tutorial](http://www.typescriptlang.org/Tutorial) -* [Programming handbook](http://www.typescriptlang.org/Handbook) +* [Quick tutorial](http://www.typescriptlang.org/docs/tutorial.html) +* [Programming handbook](http://www.typescriptlang.org/docs/handbook/basic-types.html) * [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md) * [Homepage](http://www.typescriptlang.org/) @@ -95,4 +95,4 @@ node built/local/tsc.js hello.ts ## Roadmap -For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap). \ No newline at end of file +For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap). From 7532ab2d830ff24c186160ec7aa2a80ef9fc79a0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 10 Mar 2017 17:25:31 -0800 Subject: [PATCH 136/167] Remove stray apostrophe. --- src/harness/harness.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 57041a1f2e3..29eec356148 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -761,7 +761,7 @@ namespace Harness { IO = IOImpl.Network; break; default: - throw new Error(`Unknown value '${environment}' for ExecutionEnvironment'.`); + throw new Error(`Unknown value '${environment}' for ExecutionEnvironment.`); } } From 205f63891edf75844a4eda8fce81916b9bd72819 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 10 Mar 2017 22:13:58 -0800 Subject: [PATCH 137/167] Fix Per Request Cancellation Tokens While working on https://github.com/Microsoft/vscode/pull/22437, I believe there is a bug in the per request cancellation in the `setRequest` function on the line `currentRequestId = currentRequestId ;` This causes `currentRequestId` to always be undefined Fix is to assign the `currentRequestId` to `requestId` --- src/server/cancellationToken/cancellationToken.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/cancellationToken/cancellationToken.ts b/src/server/cancellationToken/cancellationToken.ts index 0e7969c1e45..6f2f4a8897c 100644 --- a/src/server/cancellationToken/cancellationToken.ts +++ b/src/server/cancellationToken/cancellationToken.ts @@ -48,7 +48,7 @@ function createCancellationToken(args: string[]): ServerCancellationToken { return { isCancellationRequested: () => perRequestPipeName !== undefined && pipeExists(perRequestPipeName), setRequest(requestId: number) { - currentRequestId = currentRequestId; + currentRequestId = requestId; perRequestPipeName = namePrefix + requestId; }, resetRequest(requestId: number) { @@ -67,4 +67,4 @@ function createCancellationToken(args: string[]): ServerCancellationToken { }; } } -export = createCancellationToken; \ No newline at end of file +export = createCancellationToken; From 3ac54e8a47fad55c6ad88acbb682b2aed3d1b15b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Sun, 12 Mar 2017 15:00:24 -0700 Subject: [PATCH 138/167] Infer class property declarations from assignments in nested arrow functions --- src/compiler/binder.ts | 2 + .../inferringClassMembersFromAssignments.js | 78 +++++++ ...ferringClassMembersFromAssignments.symbols | 210 +++++++++++++----- ...inferringClassMembersFromAssignments.types | 130 +++++++++++ .../inferringClassMembersFromAssignments.ts | 38 ++++ 5 files changed, 406 insertions(+), 52 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 418905e604c..650797c6dba 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2332,6 +2332,7 @@ namespace ts { function bindThisPropertyAssignment(node: BinaryExpression) { Debug.assert(isInJavaScriptFile(node)); + const container = getThisContainer(node, /*includeArrowFunctions*/false); switch (container.kind) { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: @@ -2342,6 +2343,7 @@ namespace ts { break; case SyntaxKind.Constructor: + case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.js b/tests/baselines/reference/inferringClassMembersFromAssignments.js index a7b9e4ff8f0..74c47dab565 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.js +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.js @@ -20,6 +20,15 @@ class C { this.inMethod = "string" } this.inMultiple = "string"; + + var action = () => { + if (Math.random()) { + this.inNestedArrowFunction = 0; + } + else { + this.inNestedArrowFunction = "string" + } + }; } get() { if (Math.random()) { @@ -38,6 +47,14 @@ class C { this.inSetter = "string" } } + prop = () => { + if (Math.random()) { + this.inPropertyDeclaration = 0; + } + else { + this.inPropertyDeclaration = "string" + } + } static method() { if (Math.random()) { this.inStaticMethod = 0; @@ -45,6 +62,15 @@ class C { else { this.inStaticMethod = "string" } + + var action = () => { + if (Math.random()) { + this.inStaticNestedArrowFunction = 0; + } + else { + this.inStaticNestedArrowFunction = "string" + } + }; } static get() { if (Math.random()) { @@ -62,6 +88,14 @@ class C { this.inStaticSetter = "string" } } + static prop = () => { + if (Math.random()) { + this.inStaticPropertyDeclaration = 0; + } + else { + this.inStaticPropertyDeclaration = "string" + } + } } //// [b.ts] @@ -75,6 +109,8 @@ var stringOrNumberOrUndefined: string | number | undefined; var stringOrNumberOrUndefined = c.inMethod; var stringOrNumberOrUndefined = c.inGetter; var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +var stringOrNumberOrUndefined = c.inNestedArrowFunction var stringOrNumberOrBoolean: string | number | boolean; @@ -84,11 +120,23 @@ var stringOrNumberOrBoolean = c.inMultiple; var stringOrNumberOrUndefined = C.inStaticMethod; var stringOrNumberOrUndefined = C.inStaticGetter; var stringOrNumberOrUndefined = C.inStaticSetter; +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; //// [output.js] +var _this = this; var C = (function () { function C() { + var _this = this; + this.prop = function () { + if (Math.random()) { + _this.inPropertyDeclaration = 0; + } + else { + _this.inPropertyDeclaration = "string"; + } + }; if (Math.random()) { this.inConstructor = 0; } @@ -98,6 +146,7 @@ var C = (function () { this.inMultiple = 0; } C.prototype.method = function () { + var _this = this; if (Math.random()) { this.inMethod = 0; } @@ -105,6 +154,14 @@ var C = (function () { this.inMethod = "string"; } this.inMultiple = "string"; + var action = function () { + if (Math.random()) { + _this.inNestedArrowFunction = 0; + } + else { + _this.inNestedArrowFunction = "string"; + } + }; }; C.prototype.get = function () { if (Math.random()) { @@ -124,12 +181,21 @@ var C = (function () { } }; C.method = function () { + var _this = this; if (Math.random()) { this.inStaticMethod = 0; } else { this.inStaticMethod = "string"; } + var action = function () { + if (Math.random()) { + _this.inStaticNestedArrowFunction = 0; + } + else { + _this.inStaticNestedArrowFunction = "string"; + } + }; }; C.get = function () { if (Math.random()) { @@ -149,6 +215,14 @@ var C = (function () { }; return C; }()); +C.prop = function () { + if (Math.random()) { + _this.inStaticPropertyDeclaration = 0; + } + else { + _this.inStaticPropertyDeclaration = "string"; + } +}; var c = new C(); var stringOrNumber; var stringOrNumber = c.inConstructor; @@ -156,8 +230,12 @@ var stringOrNumberOrUndefined; var stringOrNumberOrUndefined = c.inMethod; var stringOrNumberOrUndefined = c.inGetter; var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +var stringOrNumberOrUndefined = c.inNestedArrowFunction; var stringOrNumberOrBoolean; var stringOrNumberOrBoolean = c.inMultiple; var stringOrNumberOrUndefined = C.inStaticMethod; var stringOrNumberOrUndefined = C.inStaticGetter; var stringOrNumberOrUndefined = C.inStaticSetter; +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.symbols b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols index 9951339f8a8..086c4246697 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.symbols +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols @@ -21,9 +21,9 @@ class C { >inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) } this.inMultiple = 0; ->this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) } method() { >method : Symbol(C.method, Decl(a.js, 10, 5)) @@ -45,12 +45,33 @@ class C { >inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) } this.inMultiple = "string"; ->this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) + + var action = () => { +>action : Symbol(action, Decl(a.js, 20, 11)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inNestedArrowFunction = 0; +>this.inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) + } + else { + this.inNestedArrowFunction = "string" +>this.inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) + } + }; } get() { ->get : Symbol(C.get, Decl(a.js, 19, 5)) +>get : Symbol(C.get, Decl(a.js, 28, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -58,23 +79,23 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inGetter = 0; ->this.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) } else { this.inGetter = "string" ->this.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) } this.inMultiple = false; ->this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) } set() { ->set : Symbol(C.set, Decl(a.js, 28, 5)) +>set : Symbol(C.set, Decl(a.js, 37, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -82,19 +103,39 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inSetter = 0; ->this.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) } else { this.inSetter = "string" ->this.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) + } + } + prop = () => { +>prop : Symbol(C.prop, Decl(a.js, 45, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inPropertyDeclaration = 0; +>this.inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) + } + else { + this.inPropertyDeclaration = "string" +>this.inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) } } static method() { ->method : Symbol(C.method, Decl(a.js, 36, 5)) +>method : Symbol(C.method, Decl(a.js, 53, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -102,19 +143,40 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inStaticMethod = 0; ->this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) } else { this.inStaticMethod = "string" ->this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) } + + var action = () => { +>action : Symbol(action, Decl(a.js, 62, 11)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticNestedArrowFunction = 0; +>this.inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) + } + else { + this.inStaticNestedArrowFunction = "string" +>this.inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) + } + }; } static get() { ->get : Symbol(C.get, Decl(a.js, 44, 5)) +>get : Symbol(C.get, Decl(a.js, 70, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -122,19 +184,19 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inStaticGetter = 0; ->this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) } else { this.inStaticGetter = "string" ->this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) } } static set() { ->set : Symbol(C.set, Decl(a.js, 52, 5)) +>set : Symbol(C.set, Decl(a.js, 78, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -142,15 +204,35 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inStaticSetter = 0; ->this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) } else { this.inStaticSetter = "string" ->this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) + } + } + static prop = () => { +>prop : Symbol(C.prop, Decl(a.js, 86, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticPropertyDeclaration = 0; +>this.inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) + } + else { + this.inStaticPropertyDeclaration = "string" +>this.inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) } } } @@ -170,51 +252,75 @@ var stringOrNumber = c.inConstructor; >inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) var stringOrNumberOrUndefined: string | number | undefined; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) var stringOrNumberOrUndefined = c.inMethod; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) >c.inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) >c : Symbol(c, Decl(b.ts, 0, 3)) >inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) var stringOrNumberOrUndefined = c.inGetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->c.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>c.inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) >c : Symbol(c, Decl(b.ts, 0, 3)) ->inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) var stringOrNumberOrUndefined = c.inSetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->c.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>c.inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) >c : Symbol(c, Decl(b.ts, 0, 3)) ->inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) + +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>c.inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) + +var stringOrNumberOrUndefined = c.inNestedArrowFunction +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>c.inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) var stringOrNumberOrBoolean: string | number | boolean; ->stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 11, 3), Decl(b.ts, 13, 3)) +>stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 13, 3), Decl(b.ts, 15, 3)) var stringOrNumberOrBoolean = c.inMultiple; ->stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 11, 3), Decl(b.ts, 13, 3)) ->c.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 13, 3), Decl(b.ts, 15, 3)) +>c.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) >c : Symbol(c, Decl(b.ts, 0, 3)) ->inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) var stringOrNumberOrUndefined = C.inStaticMethod; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->C.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) >C : Symbol(C, Decl(a.js, 0, 0)) ->inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) var stringOrNumberOrUndefined = C.inStaticGetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->C.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) >C : Symbol(C, Decl(a.js, 0, 0)) ->inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) var stringOrNumberOrUndefined = C.inStaticSetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->C.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) >C : Symbol(C, Decl(a.js, 0, 0)) ->inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) + +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) + +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.types b/tests/baselines/reference/inferringClassMembersFromAssignments.types index 547cc62ba32..d759009983c 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.types +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.types @@ -62,6 +62,33 @@ class C { >this : this >inMultiple : string | number | boolean >"string" : "string" + + var action = () => { +>action : () => void +>() => { if (Math.random()) { this.inNestedArrowFunction = 0; } else { this.inNestedArrowFunction = "string" } } : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inNestedArrowFunction = 0; +>this.inNestedArrowFunction = 0 : 0 +>this.inNestedArrowFunction : string | number | undefined +>this : this +>inNestedArrowFunction : string | number | undefined +>0 : 0 + } + else { + this.inNestedArrowFunction = "string" +>this.inNestedArrowFunction = "string" : "string" +>this.inNestedArrowFunction : string | number | undefined +>this : this +>inNestedArrowFunction : string | number | undefined +>"string" : "string" + } + }; } get() { >get : () => void @@ -116,6 +143,32 @@ class C { >this.inSetter : string | number | undefined >this : this >inSetter : string | number | undefined +>"string" : "string" + } + } + prop = () => { +>prop : () => void +>() => { if (Math.random()) { this.inPropertyDeclaration = 0; } else { this.inPropertyDeclaration = "string" } } : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inPropertyDeclaration = 0; +>this.inPropertyDeclaration = 0 : 0 +>this.inPropertyDeclaration : string | number | undefined +>this : this +>inPropertyDeclaration : string | number | undefined +>0 : 0 + } + else { + this.inPropertyDeclaration = "string" +>this.inPropertyDeclaration = "string" : "string" +>this.inPropertyDeclaration : string | number | undefined +>this : this +>inPropertyDeclaration : string | number | undefined >"string" : "string" } } @@ -143,6 +196,33 @@ class C { >inStaticMethod : string | number | undefined >"string" : "string" } + + var action = () => { +>action : () => void +>() => { if (Math.random()) { this.inStaticNestedArrowFunction = 0; } else { this.inStaticNestedArrowFunction = "string" } } : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticNestedArrowFunction = 0; +>this.inStaticNestedArrowFunction = 0 : 0 +>this.inStaticNestedArrowFunction : string | number | undefined +>this : typeof C +>inStaticNestedArrowFunction : string | number | undefined +>0 : 0 + } + else { + this.inStaticNestedArrowFunction = "string" +>this.inStaticNestedArrowFunction = "string" : "string" +>this.inStaticNestedArrowFunction : string | number | undefined +>this : typeof C +>inStaticNestedArrowFunction : string | number | undefined +>"string" : "string" + } + }; } static get() { >get : () => void @@ -191,6 +271,32 @@ class C { >this.inStaticSetter : string | number | undefined >this : typeof C >inStaticSetter : string | number | undefined +>"string" : "string" + } + } + static prop = () => { +>prop : () => void +>() => { if (Math.random()) { this.inStaticPropertyDeclaration = 0; } else { this.inStaticPropertyDeclaration = "string" } } : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticPropertyDeclaration = 0; +>this.inStaticPropertyDeclaration = 0 : 0 +>this.inStaticPropertyDeclaration : string | number | undefined +>this : typeof C +>inStaticPropertyDeclaration : string | number | undefined +>0 : 0 + } + else { + this.inStaticPropertyDeclaration = "string" +>this.inStaticPropertyDeclaration = "string" : "string" +>this.inStaticPropertyDeclaration : string | number | undefined +>this : typeof C +>inStaticPropertyDeclaration : string | number | undefined >"string" : "string" } } @@ -232,6 +338,18 @@ var stringOrNumberOrUndefined = c.inSetter; >c : C >inSetter : string | number | undefined +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +>stringOrNumberOrUndefined : string | number | undefined +>c.inPropertyDeclaration : string | number | undefined +>c : C +>inPropertyDeclaration : string | number | undefined + +var stringOrNumberOrUndefined = c.inNestedArrowFunction +>stringOrNumberOrUndefined : string | number | undefined +>c.inNestedArrowFunction : string | number | undefined +>c : C +>inNestedArrowFunction : string | number | undefined + var stringOrNumberOrBoolean: string | number | boolean; >stringOrNumberOrBoolean : string | number | boolean @@ -260,3 +378,15 @@ var stringOrNumberOrUndefined = C.inStaticSetter; >C : typeof C >inStaticSetter : string | number | undefined +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticPropertyDeclaration : string | number | undefined +>C : typeof C +>inStaticPropertyDeclaration : string | number | undefined + +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticNestedArrowFunction : string | number | undefined +>C : typeof C +>inStaticNestedArrowFunction : string | number | undefined + diff --git a/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts index d843e86b725..9cf02a9c7dd 100644 --- a/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts +++ b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts @@ -21,6 +21,15 @@ class C { this.inMethod = "string" } this.inMultiple = "string"; + + var action = () => { + if (Math.random()) { + this.inNestedArrowFunction = 0; + } + else { + this.inNestedArrowFunction = "string" + } + }; } get() { if (Math.random()) { @@ -39,6 +48,14 @@ class C { this.inSetter = "string" } } + prop = () => { + if (Math.random()) { + this.inPropertyDeclaration = 0; + } + else { + this.inPropertyDeclaration = "string" + } + } static method() { if (Math.random()) { this.inStaticMethod = 0; @@ -46,6 +63,15 @@ class C { else { this.inStaticMethod = "string" } + + var action = () => { + if (Math.random()) { + this.inStaticNestedArrowFunction = 0; + } + else { + this.inStaticNestedArrowFunction = "string" + } + }; } static get() { if (Math.random()) { @@ -63,6 +89,14 @@ class C { this.inStaticSetter = "string" } } + static prop = () => { + if (Math.random()) { + this.inStaticPropertyDeclaration = 0; + } + else { + this.inStaticPropertyDeclaration = "string" + } + } } // @filename: b.ts @@ -76,6 +110,8 @@ var stringOrNumberOrUndefined: string | number | undefined; var stringOrNumberOrUndefined = c.inMethod; var stringOrNumberOrUndefined = c.inGetter; var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +var stringOrNumberOrUndefined = c.inNestedArrowFunction var stringOrNumberOrBoolean: string | number | boolean; @@ -85,3 +121,5 @@ var stringOrNumberOrBoolean = c.inMultiple; var stringOrNumberOrUndefined = C.inStaticMethod; var stringOrNumberOrUndefined = C.inStaticGetter; var stringOrNumberOrUndefined = C.inStaticSetter; +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; From 53f04ad89c03892638cceb8a883f25a42764befc Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 13 Mar 2017 09:28:05 -0700 Subject: [PATCH 139/167] Update issue template to use TS2.2 --- issue_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/issue_template.md b/issue_template.md index 4d397a0afd6..29190e79763 100644 --- a/issue_template.md +++ b/issue_template.md @@ -2,7 +2,7 @@ -**TypeScript Version:** 2.1.1 / nightly (2.2.0-dev.201xxxxx) +**TypeScript Version:** 2.2.1 / nightly (2.2.0-dev.201xxxxx) **Code** From 3f3b05e67e35c7e97ca3c6bb76be7006aaef72f5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 13 Mar 2017 13:15:09 -0700 Subject: [PATCH 140/167] Properly track method/property distinction for intersection members --- src/compiler/checker.ts | 38 +++++++++++++++++-------------- src/compiler/types.ts | 16 +++++++------ src/services/findAllReferences.ts | 2 +- src/services/symbolDisplay.ts | 2 +- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 00498191f28..b581ca315b4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5129,7 +5129,8 @@ namespace ts { const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0; // Flags we want to propagate to the result if they exist in all source symbols let commonFlags = isUnion ? SymbolFlags.None : SymbolFlags.Optional; - let checkFlags = CheckFlags.SyntheticProperty; + let syntheticFlag = CheckFlags.SyntheticMethod; + let checkFlags = 0; for (const current of types) { const type = getApparentType(current); if (type !== unknownType) { @@ -5148,6 +5149,9 @@ namespace ts { (modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) | (modifiers & ModifierFlags.Private ? CheckFlags.ContainsPrivate : 0) | (modifiers & ModifierFlags.Static ? CheckFlags.ContainsStatic : 0); + if (!isMethodLike(prop)) { + syntheticFlag = CheckFlags.SyntheticProperty; + } } else if (isUnion) { checkFlags |= CheckFlags.Partial; @@ -5177,7 +5181,7 @@ namespace ts { propTypes.push(type); } const result = createSymbol(SymbolFlags.Property | commonFlags, name); - result.checkFlags = checkFlags; + result.checkFlags = syntheticFlag | checkFlags; result.containingType = containingType; result.declarations = declarations; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -8630,7 +8634,7 @@ namespace ts { // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop: Symbol, callback: (p: Symbol) => T): T { - if (getCheckFlags(prop) & CheckFlags.SyntheticProperty) { + if (getCheckFlags(prop) & CheckFlags.Synthetic) { for (const t of (prop).containingType.types) { const p = getPropertyOfType(t, prop.name); const result = p && forEachProperty(p, callback); @@ -13112,7 +13116,7 @@ namespace ts { const flags = getCombinedModifierFlags(s.valueDeclaration); return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier; } - if (getCheckFlags(s) & CheckFlags.SyntheticProperty) { + if (getCheckFlags(s) & CheckFlags.Synthetic) { const checkFlags = (s).checkFlags; const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private : checkFlags & CheckFlags.ContainsPublic ? ModifierFlags.Public : @@ -13130,6 +13134,10 @@ namespace ts { return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : 0; } + function isMethodLike(symbol: Symbol) { + return !!(symbol.flags & SymbolFlags.Method || getCheckFlags(symbol) & CheckFlags.SyntheticMethod); + } + /** * Check whether the requested property access is valid. * Returns true if node is a valid property access, and false otherwise. @@ -13159,11 +13167,11 @@ namespace ts { // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. if (languageVersion < ScriptTarget.ES2015) { - const propKind = getDeclarationKindFromSymbol(prop); - if (propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature) { - // `prop` refers to a *property* declared in the super class - // rather than a *method*, so it does not satisfy the above criteria. - + const hasNonMethodDeclaration = forEachProperty(prop, p => { + const propKind = getDeclarationKindFromSymbol(p); + return propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature; + }); + if (hasNonMethodDeclaration) { error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -19697,7 +19705,7 @@ namespace ts { else { // derived overrides base. const derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if ((baseDeclarationFlags & ModifierFlags.Private) || (derivedDeclarationFlags & ModifierFlags.Private)) { + if (baseDeclarationFlags & ModifierFlags.Private || derivedDeclarationFlags & ModifierFlags.Private) { // either base or derived property is private - not override, skip it continue; } @@ -19707,28 +19715,24 @@ namespace ts { continue; } - if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { + if (isMethodLike(base) && isMethodLike(derived) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { // method is overridden with method or property/accessor is overridden with property/accessor - correct case continue; } let errorMessage: DiagnosticMessage; - if (base.flags & SymbolFlags.Method) { + if (isMethodLike(base)) { if (derived.flags & SymbolFlags.Accessor) { errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - Debug.assert((derived.flags & SymbolFlags.Property) !== 0); errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & SymbolFlags.Property) { - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } @@ -21387,7 +21391,7 @@ namespace ts { } function getRootSymbols(symbol: Symbol): Symbol[] { - if (getCheckFlags(symbol) & CheckFlags.SyntheticProperty) { + if (getCheckFlags(symbol) & CheckFlags.Synthetic) { const symbols: Symbol[] = []; const name = symbol.name; forEach(getSymbolLinks(symbol).containingType.types, t => { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 97b12aeb712..e36731ff363 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2811,13 +2811,15 @@ namespace ts { export const enum CheckFlags { Instantiated = 1 << 0, // Instantiated symbol SyntheticProperty = 1 << 1, // Property in union or intersection type - Readonly = 1 << 2, // Readonly transient symbol - Partial = 1 << 3, // Synthetic property present in some but not all constituents - HasNonUniformType = 1 << 4, // Synthetic property with non-uniform type in constituents - ContainsPublic = 1 << 5, // Synthetic property with public constituent(s) - ContainsProtected = 1 << 6, // Synthetic property with protected constituent(s) - ContainsPrivate = 1 << 7, // Synthetic property with private constituent(s) - ContainsStatic = 1 << 8, // Synthetic property with static constituent(s) + SyntheticMethod = 1 << 2, // Method in union or intersection type + Readonly = 1 << 3, // Readonly transient symbol + Partial = 1 << 4, // Synthetic property present in some but not all constituents + HasNonUniformType = 1 << 5, // Synthetic property with non-uniform type in constituents + ContainsPublic = 1 << 6, // Synthetic property with public constituent(s) + ContainsProtected = 1 << 7, // Synthetic property with protected constituent(s) + ContainsPrivate = 1 << 8, // Synthetic property with private constituent(s) + ContainsStatic = 1 << 9, // Synthetic property with static constituent(s) + Synthetic = SyntheticProperty | SyntheticMethod } /* @internal */ diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index bc1e50391c8..2c999ba9fa0 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -281,7 +281,7 @@ namespace ts.FindAllReferences { // if this symbol is visible from its parent container, e.g. exported, then bail out // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.SyntheticProperty)) { + if (symbol.parent || (symbol.flags & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.Synthetic)) { return undefined; } diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index b7b739b4244..b457165b67f 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -52,7 +52,7 @@ namespace ts.SymbolDisplay { if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement; if (flags & SymbolFlags.Property) { - if (flags & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.SyntheticProperty) { + if (flags & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.Synthetic) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property const unionPropertyKind = forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { const rootSymbolFlags = rootSymbol.getFlags(); From dd84d7ca483c6a94592b592ab07fb980c21e2732 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 13 Mar 2017 13:24:14 -0700 Subject: [PATCH 141/167] Add repro --- .../overrideBaseIntersectionMethod.js | 83 ++++++++++++++ .../overrideBaseIntersectionMethod.symbols | 88 +++++++++++++++ .../overrideBaseIntersectionMethod.types | 102 ++++++++++++++++++ .../overrideBaseIntersectionMethod.ts | 31 ++++++ 4 files changed, 304 insertions(+) create mode 100644 tests/baselines/reference/overrideBaseIntersectionMethod.js create mode 100644 tests/baselines/reference/overrideBaseIntersectionMethod.symbols create mode 100644 tests/baselines/reference/overrideBaseIntersectionMethod.types create mode 100644 tests/cases/compiler/overrideBaseIntersectionMethod.ts diff --git a/tests/baselines/reference/overrideBaseIntersectionMethod.js b/tests/baselines/reference/overrideBaseIntersectionMethod.js new file mode 100644 index 00000000000..26613f07469 --- /dev/null +++ b/tests/baselines/reference/overrideBaseIntersectionMethod.js @@ -0,0 +1,83 @@ +//// [overrideBaseIntersectionMethod.ts] + +// Repro from #14615 + +type Constructor = new (...args: any[]) => T; + +const WithLocation = >(Base: T) => class extends Base { + getLocation(): [number, number] { + const [x,y] = super.getLocation(); + return [this.x | x, this.y | y]; + } +} + +class Point { + constructor(public x: number, public y: number) { } + getLocation(): [number, number] { + return [0,0]; + } +} + +class Foo extends WithLocation(Point) { + calculate() { + return this.x + this.y; + } + getLocation() { + return super.getLocation() + } + whereAmI() { + return this.getLocation(); + } +} + + +//// [overrideBaseIntersectionMethod.js] +// Repro from #14615 +"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]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var WithLocation = function (Base) { return (function (_super) { + __extends(class_1, _super); + function class_1() { + return _super !== null && _super.apply(this, arguments) || this; + } + class_1.prototype.getLocation = function () { + var _a = _super.prototype.getLocation.call(this), x = _a[0], y = _a[1]; + return [this.x | x, this.y | y]; + }; + return class_1; +}(Base)); }; +var Point = (function () { + function Point(x, y) { + this.x = x; + this.y = y; + } + Point.prototype.getLocation = function () { + return [0, 0]; + }; + return Point; +}()); +var Foo = (function (_super) { + __extends(Foo, _super); + function Foo() { + return _super !== null && _super.apply(this, arguments) || this; + } + Foo.prototype.calculate = function () { + return this.x + this.y; + }; + Foo.prototype.getLocation = function () { + return _super.prototype.getLocation.call(this); + }; + Foo.prototype.whereAmI = function () { + return this.getLocation(); + }; + return Foo; +}(WithLocation(Point))); diff --git a/tests/baselines/reference/overrideBaseIntersectionMethod.symbols b/tests/baselines/reference/overrideBaseIntersectionMethod.symbols new file mode 100644 index 00000000000..45a84543408 --- /dev/null +++ b/tests/baselines/reference/overrideBaseIntersectionMethod.symbols @@ -0,0 +1,88 @@ +=== tests/cases/compiler/overrideBaseIntersectionMethod.ts === + +// Repro from #14615 + +type Constructor = new (...args: any[]) => T; +>Constructor : Symbol(Constructor, Decl(overrideBaseIntersectionMethod.ts, 0, 0)) +>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 3, 17)) +>args : Symbol(args, Decl(overrideBaseIntersectionMethod.ts, 3, 27)) +>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 3, 17)) + +const WithLocation = >(Base: T) => class extends Base { +>WithLocation : Symbol(WithLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 5)) +>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 5, 22)) +>Constructor : Symbol(Constructor, Decl(overrideBaseIntersectionMethod.ts, 0, 0)) +>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1)) +>Base : Symbol(Base, Decl(overrideBaseIntersectionMethod.ts, 5, 52)) +>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 5, 22)) +>Base : Symbol(Base, Decl(overrideBaseIntersectionMethod.ts, 5, 52)) + + getLocation(): [number, number] { +>getLocation : Symbol((Anonymous class).getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84)) + + const [x,y] = super.getLocation(); +>x : Symbol(x, Decl(overrideBaseIntersectionMethod.ts, 7, 11)) +>y : Symbol(y, Decl(overrideBaseIntersectionMethod.ts, 7, 13)) +>super.getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53)) +>super : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1)) +>getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53)) + + return [this.x | x, this.y | y]; +>this.x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>this : Symbol((Anonymous class), Decl(overrideBaseIntersectionMethod.ts, 5, 63)) +>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>x : Symbol(x, Decl(overrideBaseIntersectionMethod.ts, 7, 11)) +>this.y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) +>this : Symbol((Anonymous class), Decl(overrideBaseIntersectionMethod.ts, 5, 63)) +>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) +>y : Symbol(y, Decl(overrideBaseIntersectionMethod.ts, 7, 13)) + } +} + +class Point { +>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1)) + + constructor(public x: number, public y: number) { } +>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) + + getLocation(): [number, number] { +>getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53)) + + return [0,0]; + } +} + +class Foo extends WithLocation(Point) { +>Foo : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1)) +>WithLocation : Symbol(WithLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 5)) +>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1)) + + calculate() { +>calculate : Symbol(Foo.calculate, Decl(overrideBaseIntersectionMethod.ts, 19, 39)) + + return this.x + this.y; +>this.x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1)) +>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>this.y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) +>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1)) +>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) + } + getLocation() { +>getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3)) + + return super.getLocation() +>super.getLocation : Symbol(getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84), Decl(overrideBaseIntersectionMethod.ts, 13, 53)) +>getLocation : Symbol(getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84), Decl(overrideBaseIntersectionMethod.ts, 13, 53)) + } + whereAmI() { +>whereAmI : Symbol(Foo.whereAmI, Decl(overrideBaseIntersectionMethod.ts, 25, 3)) + + return this.getLocation(); +>this.getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3)) +>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1)) +>getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3)) + } +} + diff --git a/tests/baselines/reference/overrideBaseIntersectionMethod.types b/tests/baselines/reference/overrideBaseIntersectionMethod.types new file mode 100644 index 00000000000..3e31211bdbf --- /dev/null +++ b/tests/baselines/reference/overrideBaseIntersectionMethod.types @@ -0,0 +1,102 @@ +=== tests/cases/compiler/overrideBaseIntersectionMethod.ts === + +// Repro from #14615 + +type Constructor = new (...args: any[]) => T; +>Constructor : Constructor +>T : T +>args : any[] +>T : T + +const WithLocation = >(Base: T) => class extends Base { +>WithLocation : >(Base: T) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & T +>>(Base: T) => class extends Base { getLocation(): [number, number] { const [x,y] = super.getLocation(); return [this.x | x, this.y | y]; }} : >(Base: T) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & T +>T : T +>Constructor : Constructor +>Point : Point +>Base : T +>T : T +>class extends Base { getLocation(): [number, number] { const [x,y] = super.getLocation(); return [this.x | x, this.y | y]; }} : { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & T +>Base : Point + + getLocation(): [number, number] { +>getLocation : () => [number, number] + + const [x,y] = super.getLocation(); +>x : number +>y : number +>super.getLocation() : [number, number] +>super.getLocation : () => [number, number] +>super : Point +>getLocation : () => [number, number] + + return [this.x | x, this.y | y]; +>[this.x | x, this.y | y] : [number, number] +>this.x | x : number +>this.x : number +>this : this +>x : number +>x : number +>this.y | y : number +>this.y : number +>this : this +>y : number +>y : number + } +} + +class Point { +>Point : Point + + constructor(public x: number, public y: number) { } +>x : number +>y : number + + getLocation(): [number, number] { +>getLocation : () => [number, number] + + return [0,0]; +>[0,0] : [number, number] +>0 : 0 +>0 : 0 + } +} + +class Foo extends WithLocation(Point) { +>Foo : Foo +>WithLocation(Point) : .(Anonymous class) & Point +>WithLocation : >(Base: T) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & T +>Point : typeof Point + + calculate() { +>calculate : () => number + + return this.x + this.y; +>this.x + this.y : number +>this.x : number +>this : this +>x : number +>this.y : number +>this : this +>y : number + } + getLocation() { +>getLocation : () => [number, number] + + return super.getLocation() +>super.getLocation() : [number, number] +>super.getLocation : () => [number, number] +>super : .(Anonymous class) & Point +>getLocation : () => [number, number] + } + whereAmI() { +>whereAmI : () => [number, number] + + return this.getLocation(); +>this.getLocation() : [number, number] +>this.getLocation : () => [number, number] +>this : this +>getLocation : () => [number, number] + } +} + diff --git a/tests/cases/compiler/overrideBaseIntersectionMethod.ts b/tests/cases/compiler/overrideBaseIntersectionMethod.ts new file mode 100644 index 00000000000..99cd4664bc5 --- /dev/null +++ b/tests/cases/compiler/overrideBaseIntersectionMethod.ts @@ -0,0 +1,31 @@ +// @strict: true + +// Repro from #14615 + +type Constructor = new (...args: any[]) => T; + +const WithLocation = >(Base: T) => class extends Base { + getLocation(): [number, number] { + const [x,y] = super.getLocation(); + return [this.x | x, this.y | y]; + } +} + +class Point { + constructor(public x: number, public y: number) { } + getLocation(): [number, number] { + return [0,0]; + } +} + +class Foo extends WithLocation(Point) { + calculate() { + return this.x + this.y; + } + getLocation() { + return super.getLocation() + } + whereAmI() { + return this.getLocation(); + } +} From d86976a9efba2d573a808b4644efc28afd67c978 Mon Sep 17 00:00:00 2001 From: falsandtru Date: Tue, 14 Mar 2017 08:06:00 +0900 Subject: [PATCH 142/167] Convert overloads to unions --- src/lib/es5.d.ts | 47 +++---------------- .../reference/bestChoiceType.symbols | 12 ++--- .../baselines/reference/bestChoiceType.types | 12 ++--- .../controlFlowPropertyDeclarations.symbols | 8 ++-- .../controlFlowPropertyDeclarations.types | 8 ++-- ...nContextuallyTypesFunctionParamter.symbols | 4 +- ...yInContextuallyTypesFunctionParamter.types | 4 +- ...overloadResolutionOverNonCTLambdas.symbols | 4 +- .../overloadResolutionOverNonCTLambdas.types | 4 +- .../baselines/reference/parser630933.symbols | 4 +- tests/baselines/reference/parser630933.types | 4 +- .../regExpWithSlashInCharClass.symbols | 12 ++--- .../regExpWithSlashInCharClass.types | 12 ++--- 13 files changed, 51 insertions(+), 84 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 61f8e396471..7d3a2179a38 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -325,53 +325,27 @@ interface String { * Matches a string with a regular expression, and returns an array containing the results of that search. * @param regexp A variable name or string literal containing the regular expression pattern and flags. */ - match(regexp: string): RegExpMatchArray | null; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. - */ - match(regexp: RegExp): RegExpMatchArray | null; + match(regexp: string | RegExp): RegExpMatchArray | null; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ - replace(searchValue: string, replaceValue: string): string; + replace(searchValue: string | RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. - */ - replace(searchValue: RegExp, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replacer A function that returns the replacement text. - */ - replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. * @param regexp The regular expression pattern and applicable flags. */ - search(regexp: string): number; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: RegExp): number; + search(regexp: string | RegExp): number; /** * Returns a section of a string. @@ -386,14 +360,7 @@ interface String { * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. * @param limit A value used to limit the number of elements returned in the array. */ - split(separator: string, limit?: number): string[]; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: RegExp, limit?: number): string[]; + split(separator: string | RegExp, limit?: number): string[]; /** * Returns the substring at the specified location within a String object. @@ -861,9 +828,9 @@ interface RegExp { } interface RegExpConstructor { - new (pattern: RegExp): RegExp; + new (pattern: RegExp | string): RegExp; new (pattern: string, flags?: string): RegExp; - (pattern: RegExp): RegExp; + (pattern: RegExp | string): RegExp; (pattern: string, flags?: string): RegExp; readonly prototype: RegExp; diff --git a/tests/baselines/reference/bestChoiceType.symbols b/tests/baselines/reference/bestChoiceType.symbols index 45f4342992e..d6197ad9a6b 100644 --- a/tests/baselines/reference/bestChoiceType.symbols +++ b/tests/baselines/reference/bestChoiceType.symbols @@ -4,8 +4,8 @@ (''.match(/ /) || []).map(s => s.toLowerCase()); >(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>''.match : Symbol(String.match, Decl(lib.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.d.ts, --, --)) >map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 3, 26)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) @@ -19,8 +19,8 @@ function f1() { let x = ''.match(/ /); >x : Symbol(x, Decl(bestChoiceType.ts, 8, 7)) ->''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>''.match : Symbol(String.match, Decl(lib.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.d.ts, --, --)) let y = x || []; >y : Symbol(y, Decl(bestChoiceType.ts, 9, 7)) @@ -42,8 +42,8 @@ function f2() { let x = ''.match(/ /); >x : Symbol(x, Decl(bestChoiceType.ts, 14, 7)) ->''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>''.match : Symbol(String.match, Decl(lib.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.d.ts, --, --)) let y = x ? x : []; >y : Symbol(y, Decl(bestChoiceType.ts, 15, 7)) diff --git a/tests/baselines/reference/bestChoiceType.types b/tests/baselines/reference/bestChoiceType.types index 3a540e97d59..1aa35c8da9e 100644 --- a/tests/baselines/reference/bestChoiceType.types +++ b/tests/baselines/reference/bestChoiceType.types @@ -8,9 +8,9 @@ >(''.match(/ /) || []) : RegExpMatchArray >''.match(/ /) || [] : RegExpMatchArray >''.match(/ /) : RegExpMatchArray | null ->''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>''.match : (regexp: string | RegExp) => RegExpMatchArray | null >'' : "" ->match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>match : (regexp: string | RegExp) => RegExpMatchArray | null >/ / : RegExp >[] : never[] >map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } @@ -29,9 +29,9 @@ function f1() { let x = ''.match(/ /); >x : RegExpMatchArray | null >''.match(/ /) : RegExpMatchArray | null ->''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>''.match : (regexp: string | RegExp) => RegExpMatchArray | null >'' : "" ->match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>match : (regexp: string | RegExp) => RegExpMatchArray | null >/ / : RegExp let y = x || []; @@ -60,9 +60,9 @@ function f2() { let x = ''.match(/ /); >x : RegExpMatchArray | null >''.match(/ /) : RegExpMatchArray | null ->''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>''.match : (regexp: string | RegExp) => RegExpMatchArray | null >'' : "" ->match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>match : (regexp: string | RegExp) => RegExpMatchArray | null >/ / : RegExp let y = x ? x : []; diff --git a/tests/baselines/reference/controlFlowPropertyDeclarations.symbols b/tests/baselines/reference/controlFlowPropertyDeclarations.symbols index 8e87d71ae33..fdaa61c2e2d 100644 --- a/tests/baselines/reference/controlFlowPropertyDeclarations.symbols +++ b/tests/baselines/reference/controlFlowPropertyDeclarations.symbols @@ -220,15 +220,15 @@ export class HTMLtoJSX { // wrapping newlines and sequences of two or more spaces in variables. text = text >text : Symbol(text, Decl(controlFlowPropertyDeclarations.ts, 113, 7)) ->text .replace(/\r/g, '') .replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->text .replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>text .replace(/\r/g, '') .replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>text .replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >text : Symbol(text, Decl(controlFlowPropertyDeclarations.ts, 113, 7)) .replace(/\r/g, '') ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) .replace(/( {2,}|\n|\t|\{|\})/g, function(whitespace) { ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >whitespace : Symbol(whitespace, Decl(controlFlowPropertyDeclarations.ts, 121, 50)) return '{' + JSON.stringify(whitespace) + '}'; diff --git a/tests/baselines/reference/controlFlowPropertyDeclarations.types b/tests/baselines/reference/controlFlowPropertyDeclarations.types index fae5ed27da2..286124ca346 100644 --- a/tests/baselines/reference/controlFlowPropertyDeclarations.types +++ b/tests/baselines/reference/controlFlowPropertyDeclarations.types @@ -295,18 +295,18 @@ export class HTMLtoJSX { >text = text .replace(/\r/g, '') .replace(/( {2,}|\n|\t|\{|\})/g, function(whitespace) { return '{' + JSON.stringify(whitespace) + '}'; }) : string >text : string >text .replace(/\r/g, '') .replace(/( {2,}|\n|\t|\{|\})/g, function(whitespace) { return '{' + JSON.stringify(whitespace) + '}'; }) : string ->text .replace(/\r/g, '') .replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>text .replace(/\r/g, '') .replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >text .replace(/\r/g, '') : string ->text .replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>text .replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >text : string .replace(/\r/g, '') ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/\r/g : RegExp >'' : "" .replace(/( {2,}|\n|\t|\{|\})/g, function(whitespace) { ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/( {2,}|\n|\t|\{|\})/g : RegExp >function(whitespace) { return '{' + JSON.stringify(whitespace) + '}'; } : (whitespace: string) => string >whitespace : string diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols index e2e776cf72e..45b62e29b8a 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols @@ -8,7 +8,7 @@ regexMatchList.forEach(match => ''.replace(match, '')); >regexMatchList : Symbol(regexMatchList, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 1, 3)) >forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) ->''.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>''.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types index d7cb482a51c..100d64482ce 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types @@ -14,9 +14,9 @@ regexMatchList.forEach(match => ''.replace(match, '')); >match => ''.replace(match, '') : (this: undefined, match: string) => string >match : string >''.replace(match, '') : string ->''.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>''.replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >'' : "" ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >match : string >'' : "" diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols index 02390079e38..0070954bb1e 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols @@ -14,9 +14,9 @@ module Bugs { var result= message.replace(/\{(\d+)\}/g, function(match, ...rest) { >result : Symbol(result, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 7)) ->message.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>message.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >message : Symbol(message, Decl(overloadResolutionOverNonCTLambdas.ts, 5, 16)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(match, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 55)) >rest : Symbol(rest, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 61)) diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types index a4de1666d0b..ce2171f1e9a 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types @@ -15,9 +15,9 @@ module Bugs { var result= message.replace(/\{(\d+)\}/g, function(match, ...rest) { >result : string >message.replace(/\{(\d+)\}/g, function(match, ...rest) { var index= rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; }) : string ->message.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>message.replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >message : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/\{(\d+)\}/g : RegExp >function(match, ...rest) { var index= rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; } : (match: string, ...rest: any[]) => any >match : string diff --git a/tests/baselines/reference/parser630933.symbols b/tests/baselines/reference/parser630933.symbols index 0f2ac0679e0..8aff3b01ffd 100644 --- a/tests/baselines/reference/parser630933.symbols +++ b/tests/baselines/reference/parser630933.symbols @@ -4,7 +4,7 @@ var a = "Hello"; var b = a.match(/\/ver=([^/]+)/); >b : Symbol(b, Decl(parser630933.ts, 1, 3)) ->a.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a.match : Symbol(String.match, Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(parser630933.ts, 0, 3)) ->match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/parser630933.types b/tests/baselines/reference/parser630933.types index 9a0ba9e7205..7b38c188f2d 100644 --- a/tests/baselines/reference/parser630933.types +++ b/tests/baselines/reference/parser630933.types @@ -6,8 +6,8 @@ var a = "Hello"; var b = a.match(/\/ver=([^/]+)/); >b : RegExpMatchArray >a.match(/\/ver=([^/]+)/) : RegExpMatchArray ->a.match : { (regexp: string): RegExpMatchArray; (regexp: RegExp): RegExpMatchArray; } +>a.match : (regexp: string | RegExp) => RegExpMatchArray >a : string ->match : { (regexp: string): RegExpMatchArray; (regexp: RegExp): RegExpMatchArray; } +>match : (regexp: string | RegExp) => RegExpMatchArray >/\/ver=([^/]+)/ : RegExp diff --git a/tests/baselines/reference/regExpWithSlashInCharClass.symbols b/tests/baselines/reference/regExpWithSlashInCharClass.symbols index 105724b12f1..6ee33e12b45 100644 --- a/tests/baselines/reference/regExpWithSlashInCharClass.symbols +++ b/tests/baselines/reference/regExpWithSlashInCharClass.symbols @@ -1,16 +1,16 @@ === tests/cases/compiler/regExpWithSlashInCharClass.ts === var foo1 = "a/".replace(/.[/]/, ""); >foo1 : Symbol(foo1, Decl(regExpWithSlashInCharClass.ts, 0, 3)) ->"a/".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>"a/".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) var foo2 = "a//".replace(/.[//]/g, ""); >foo2 : Symbol(foo2, Decl(regExpWithSlashInCharClass.ts, 1, 3)) ->"a//".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>"a//".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix"); >foo3 : Symbol(foo3, Decl(regExpWithSlashInCharClass.ts, 2, 3)) ->"a/".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>"a/".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/regExpWithSlashInCharClass.types b/tests/baselines/reference/regExpWithSlashInCharClass.types index e866f2bc229..1c980ca8d8b 100644 --- a/tests/baselines/reference/regExpWithSlashInCharClass.types +++ b/tests/baselines/reference/regExpWithSlashInCharClass.types @@ -2,27 +2,27 @@ var foo1 = "a/".replace(/.[/]/, ""); >foo1 : string >"a/".replace(/.[/]/, "") : string ->"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>"a/".replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a/" : "a/" ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/]/ : RegExp >"" : "" var foo2 = "a//".replace(/.[//]/g, ""); >foo2 : string >"a//".replace(/.[//]/g, "") : string ->"a//".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>"a//".replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a//" : "a//" ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[//]/g : RegExp >"" : "" var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix"); >foo3 : string >"a/".replace(/.[/no sleep /till/]/, "bugfix") : string ->"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>"a/".replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a/" : "a/" ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/no sleep /till/]/ : RegExp >"bugfix" : "bugfix" From 8aa7e224aa58fcd33934877481dff446bf69a22d Mon Sep 17 00:00:00 2001 From: cedvdb Date: Tue, 14 Mar 2017 00:08:18 +0100 Subject: [PATCH 143/167] added entries foreach values and keys --- lib/lib.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 126e5d82ac4..f48dd389616 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -18053,6 +18053,10 @@ declare var URLSearchParams: { interface NodeListOf extends NodeList { length: number; item(index: number): TNode; + keys(): ArrayLike; + values(): ArrayLike<[number, TNode]>; + entries(): ArrayLike; + forEach():void; [index: number]: TNode; } From 5f37d32dbf049b36f5a56a648e87865be122aa53 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Tue, 14 Mar 2017 00:52:47 +0100 Subject: [PATCH 144/167] added `keys`, `entries`, `values`, `forEach` on NodeListOf --- lib/lib.d.ts | 4 ---- src/lib/dom.iterable.d.ts | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/lib.d.ts b/lib/lib.d.ts index f48dd389616..126e5d82ac4 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -18053,10 +18053,6 @@ declare var URLSearchParams: { interface NodeListOf extends NodeList { length: number; item(index: number): TNode; - keys(): ArrayLike; - values(): ArrayLike<[number, TNode]>; - entries(): ArrayLike; - forEach():void; [index: number]: TNode; } diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 7f653dc8e0c..4e9112a9a44 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,9 +5,14 @@ interface DOMTokenList { } interface NodeList { + [Symbol.iterator](): IterableIterator } interface NodeListOf { + keys(): IterableIterator; + values(): IterableIterator<[number, TNode]>; + entries(): IterableIterator; + forEach(): void; [Symbol.iterator](): IterableIterator } From 875328c123557879a887ea0e558b32ca912372ac Mon Sep 17 00:00:00 2001 From: cedvdb Date: Tue, 14 Mar 2017 00:55:41 +0100 Subject: [PATCH 145/167] removed white space --- src/lib/dom.iterable.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 4e9112a9a44..34c91aa148b 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,7 +5,6 @@ interface DOMTokenList { } interface NodeList { - [Symbol.iterator](): IterableIterator } From 8cac5285b90b7c8a19741c0f74958353a5c79d2d Mon Sep 17 00:00:00 2001 From: cedvdb Date: Tue, 14 Mar 2017 04:15:32 +0100 Subject: [PATCH 146/167] added `keys`, `values`, ``forEach, `entries` to nodelist --- src/lib/dom.iterable.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 34c91aa148b..fb862376a24 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,6 +5,10 @@ interface DOMTokenList { } interface NodeList { + keys(): IterableIterator; + values(): IterableIterator<[number, Node]>; + entries(): IterableIterator; + forEach(): void; [Symbol.iterator](): IterableIterator } From 45ae0b453cc75d53c42fd0450512bfbb24e47c6c Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 01:15:15 +0100 Subject: [PATCH 147/167] change to forEach method --- src/lib/dom.iterable.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index fb862376a24..35afb0ddd5c 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -8,7 +8,7 @@ interface NodeList { keys(): IterableIterator; values(): IterableIterator<[number, Node]>; entries(): IterableIterator; - forEach(): void; + forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; [Symbol.iterator](): IterableIterator } @@ -16,6 +16,6 @@ interface NodeListOf { keys(): IterableIterator; values(): IterableIterator<[number, TNode]>; entries(): IterableIterator; - forEach(): void; + forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; [Symbol.iterator](): IterableIterator } From 64070632dc9f578e98843b85bc0dfdc3e2681624 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:06:25 +0100 Subject: [PATCH 148/167] added comments --- src/lib/dom.iterable.d.ts | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 35afb0ddd5c..543f49e3751 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,17 +5,40 @@ interface DOMTokenList { } interface NodeList { - keys(): IterableIterator; - values(): IterableIterator<[number, Node]>; + + /** + * Returns an list of values in the list + */ entries(): IterableIterator; + forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the list + */ + values(): IterableIterator<[number, Node]>; + + [Symbol.iterator](): IterableIterator } interface NodeListOf { + /** + * Returns an list of values in the list + */ + entries(): IterableIterator; + + forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ keys(): IterableIterator; - values(): IterableIterator<[number, TNode]>; - entries(): IterableIterator; - forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; + /** + * Returns an array of key, value pairs for every entry in the list + */ + values(): IterableIterator<[number, Node]>; [Symbol.iterator](): IterableIterator } From d9cab8331433744ee7b975ba610d2292a5f9fe72 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:08:16 +0100 Subject: [PATCH 149/167] Change Node to TNode in NodeListOf --- src/lib/dom.iterable.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 543f49e3751..bb6d75aa657 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -29,9 +29,9 @@ interface NodeListOf { /** * Returns an list of values in the list */ - entries(): IterableIterator; + entries(): IterableIterator; - forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + forEach(callbackfn: (value: TNode, index: number, listObj: NodeList) => void, thisArg?: any): void; /** * Returns an list of keys in the list */ @@ -39,6 +39,6 @@ interface NodeListOf { /** * Returns an array of key, value pairs for every entry in the list */ - values(): IterableIterator<[number, Node]>; + values(): IterableIterator<[number, TNode]>; [Symbol.iterator](): IterableIterator } From f20c59a7d287584a0c9b0cdfe8c6eca5b8049caf Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:10:40 +0100 Subject: [PATCH 150/167] change NodeList to NodeListOf in NodeListOf.forEach --- src/lib/dom.iterable.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index bb6d75aa657..a3f3f238fb2 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -31,7 +31,7 @@ interface NodeListOf { */ entries(): IterableIterator; - forEach(callbackfn: (value: TNode, index: number, listObj: NodeList) => void, thisArg?: any): void; + forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; /** * Returns an list of keys in the list */ From 8d0e0f3f795193c22b3f7ddfabc0759e20e6ae64 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:12:08 +0100 Subject: [PATCH 151/167] Added comment for forEach --- src/lib/dom.iterable.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index a3f3f238fb2..ebdb01603e7 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -10,7 +10,9 @@ interface NodeList { * Returns an list of values in the list */ entries(): IterableIterator; - + /** + * Executes a provided function once per NodeList element. + */ forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; /** * Returns an list of keys in the list @@ -30,7 +32,10 @@ interface NodeListOf { * Returns an list of values in the list */ entries(): IterableIterator; - + + /** + * Executes a provided function once per NodeList element. + */ forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; /** * Returns an list of keys in the list From db878adea31c025328276cdba365f578ba9acd7b Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:15:58 +0100 Subject: [PATCH 152/167] changed forEach comment --- src/lib/dom.iterable.d.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index ebdb01603e7..3badfc39a3e 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -10,9 +10,11 @@ interface NodeList { * Returns an list of values in the list */ entries(): IterableIterator; - /** - * Executes a provided function once per NodeList element. - */ + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; /** * Returns an list of keys in the list @@ -33,9 +35,11 @@ interface NodeListOf { */ entries(): IterableIterator; - /** - * Executes a provided function once per NodeList element. - */ + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; /** * Returns an list of keys in the list From e8b6e8b0f1328484156f763b71bc9050410568d5 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 12:48:55 +0100 Subject: [PATCH 153/167] swap entries and values --- src/lib/dom.iterable.d.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 3badfc39a3e..e4da7a62763 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -6,10 +6,11 @@ interface DOMTokenList { interface NodeList { + /** - * Returns an list of values in the list - */ - entries(): IterableIterator; + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, Node]>; /** * Performs the specified action for each node in an list. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. @@ -20,20 +21,22 @@ interface NodeList { * Returns an list of keys in the list */ keys(): IterableIterator; + /** - * Returns an array of key, value pairs for every entry in the list + * Returns an list of values in the list */ - values(): IterableIterator<[number, Node]>; + values(): IterableIterator; [Symbol.iterator](): IterableIterator } interface NodeListOf { + /** - * Returns an list of values in the list - */ - entries(): IterableIterator; + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, TNode]>; /** * Performs the specified action for each node in an list. @@ -46,8 +49,9 @@ interface NodeListOf { */ keys(): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the list + * Returns an list of values in the list */ - values(): IterableIterator<[number, TNode]>; + values(): IterableIterator; + [Symbol.iterator](): IterableIterator } From 2b10611fbfb63c4fe24d865dc275fec016af003e Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 15 Mar 2017 11:44:36 -0700 Subject: [PATCH 154/167] initial revision of infrastructure to produce text changes that uses existing node factory, formatter and printer (#14441) initial revision of infrastructure to produce text changes that uses existing node factory, formatter and printer --- Jakefile.js | 5 +- src/compiler/emitter.ts | 33 +- src/compiler/factory.ts | 4 + src/compiler/scanner.ts | 2 +- src/compiler/types.ts | 12 + src/compiler/utilities.ts | 14 +- src/compiler/visitor.ts | 150 ++-- src/harness/fourslash.ts | 11 +- src/harness/tsconfig.json | 3 +- src/harness/unittests/textChanges.ts | 791 ++++++++++++++++++ src/server/session.ts | 3 +- src/services/codeFixProvider.ts | 1 + .../fixClassSuperMustPrecedeThisAccess.ts | 17 +- .../fixConstructorForDerivedNeedSuperCall.ts | 7 +- .../fixExtendsInterfaceBecomesImplements.ts | 14 +- .../fixForgottenThisPropertyAccess.ts | 8 +- src/services/codefixes/importFixes.ts | 103 +-- .../codefixes/unusedIdentifierFixes.ts | 133 ++- src/services/formatting/formatting.ts | 50 +- src/services/formatting/formattingContext.ts | 2 +- src/services/formatting/formattingScanner.ts | 10 +- src/services/formatting/rulesProvider.ts | 4 + src/services/formatting/smartIndenter.ts | 87 +- src/services/services.ts | 14 +- src/services/textChanges.ts | 666 +++++++++++++++ src/services/tsconfig.json | 1 + src/services/types.ts | 10 +- src/services/utilities.ts | 14 +- .../reference/textChanges/deleteNode1.js | 13 + .../reference/textChanges/deleteNode2.js | 12 + .../reference/textChanges/deleteNode3.js | 14 + .../reference/textChanges/deleteNode4.js | 13 + .../reference/textChanges/deleteNode5.js | 16 + .../textChanges/deleteNodeAfterInClass1.js | 12 + .../textChanges/deleteNodeAfterInClass2.js | 12 + .../textChanges/deleteNodeInList1.js | 4 + .../textChanges/deleteNodeInList10.js | 10 + .../textChanges/deleteNodeInList11.js | 10 + .../textChanges/deleteNodeInList12.js | 10 + .../textChanges/deleteNodeInList13.js | 15 + .../textChanges/deleteNodeInList14.js | 15 + .../textChanges/deleteNodeInList15.js | 15 + .../textChanges/deleteNodeInList1_1.js | 4 + .../textChanges/deleteNodeInList2.js | 4 + .../textChanges/deleteNodeInList2_1.js | 4 + .../textChanges/deleteNodeInList3.js | 4 + .../textChanges/deleteNodeInList3_1.js | 4 + .../textChanges/deleteNodeInList4.js | 13 + .../textChanges/deleteNodeInList4_1.js | 17 + .../textChanges/deleteNodeInList5.js | 13 + .../textChanges/deleteNodeInList5_1.js | 16 + .../textChanges/deleteNodeInList6.js | 13 + .../textChanges/deleteNodeInList6_1.js | 16 + .../textChanges/deleteNodeInList7.js | 10 + .../textChanges/deleteNodeInList8.js | 10 + .../textChanges/deleteNodeInList9.js | 10 + .../reference/textChanges/deleteNodeRange1.js | 16 + .../reference/textChanges/deleteNodeRange2.js | 15 + .../reference/textChanges/deleteNodeRange3.js | 17 + .../reference/textChanges/deleteNodeRange4.js | 16 + .../reference/textChanges/deleteRange1.js | 15 + .../textChanges/extractMethodLike.js | 49 ++ .../reference/textChanges/insertNodeAfter1.js | 26 + .../reference/textChanges/insertNodeAfter2.js | 26 + .../insertNodeAfter3-block with newline.js | 16 + .../reference/textChanges/insertNodeAfter3.js | 14 + .../reference/textChanges/insertNodeAfter4.js | 16 + .../textChanges/insertNodeAfterInClass1.js | 12 + .../textChanges/insertNodeAfterInClass2.js | 12 + .../insertNodeAfterMultipleNodes.js | 21 + .../reference/textChanges/insertNodeAt1.js | 22 + .../reference/textChanges/insertNodeAt2.js | 20 + .../textChanges/insertNodeBefore1.js | 26 + .../textChanges/insertNodeBefore2.js | 26 + ...rtNodeInClassAfterNodeWithoutSeparator1.js | 12 + ...rtNodeInClassAfterNodeWithoutSeparator2.js | 14 + ...deInInterfaceAfterNodeWithoutSeparator1.js | 12 + ...deInInterfaceAfterNodeWithoutSeparator2.js | 12 + .../textChanges/insertNodeInListAfter1.js | 6 + .../textChanges/insertNodeInListAfter10.js | 10 + .../textChanges/insertNodeInListAfter11.js | 11 + .../textChanges/insertNodeInListAfter12.js | 10 + .../textChanges/insertNodeInListAfter13.js | 11 + .../textChanges/insertNodeInListAfter14.js | 13 + .../textChanges/insertNodeInListAfter15.js | 13 + .../textChanges/insertNodeInListAfter16.js | 13 + .../textChanges/insertNodeInListAfter17.js | 13 + .../textChanges/insertNodeInListAfter18.js | 10 + .../textChanges/insertNodeInListAfter2.js | 6 + .../textChanges/insertNodeInListAfter3.js | 6 + .../textChanges/insertNodeInListAfter4.js | 6 + .../textChanges/insertNodeInListAfter5.js | 6 + .../textChanges/insertNodeInListAfter6.js | 9 + .../textChanges/insertNodeInListAfter7.js | 9 + .../textChanges/insertNodeInListAfter8.js | 9 + .../textChanges/insertNodeInListAfter9.js | 9 + ...StatementListAfterNodeWithoutSeparator1.js | 8 + .../reference/textChanges/replaceNode1.js | 20 + .../replaceNode1NoLineBreakBefore.js | 13 + .../reference/textChanges/replaceNode2.js | 20 + .../reference/textChanges/replaceNode3.js | 21 + .../reference/textChanges/replaceNode4.js | 19 + .../reference/textChanges/replaceNode5.js | 19 + .../textChanges/replaceNodeRange1.js | 19 + .../textChanges/replaceNodeRange2.js | 19 + .../textChanges/replaceNodeRange3.js | 20 + .../textChanges/replaceNodeRange4.js | 18 + .../reference/textChanges/replaceRange.js | 19 + .../replaceRangeNoLineBreakBefore.js | 6 + .../replaceRangeWithForcedIndentation.js | 19 + .../fourslash/codeFixAddForgottenThis01.ts | 10 +- .../cases/fourslash/codeFixSuperAfterThis.ts | 10 +- tests/cases/fourslash/codeFixSuperCall.ts | 11 +- .../importNameCodeFixExistingImport10.ts | 2 +- .../importNameCodeFixExistingImport11.ts | 3 +- .../importNameCodeFixExistingImport9.ts | 3 +- .../fourslash/unusedFunctionInNamespace1.ts | 1 - .../fourslash/unusedVariableInForLoop7FS.ts | 18 +- 118 files changed, 3015 insertions(+), 346 deletions(-) create mode 100644 src/harness/unittests/textChanges.ts create mode 100644 src/services/textChanges.ts create mode 100644 tests/baselines/reference/textChanges/deleteNode1.js create mode 100644 tests/baselines/reference/textChanges/deleteNode2.js create mode 100644 tests/baselines/reference/textChanges/deleteNode3.js create mode 100644 tests/baselines/reference/textChanges/deleteNode4.js create mode 100644 tests/baselines/reference/textChanges/deleteNode5.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList10.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList11.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList12.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList13.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList14.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList15.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList1_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList2.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList2_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList3.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList3_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList4.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList4_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList5.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList5_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList6.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList6_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList7.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList8.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList9.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange2.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange3.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange4.js create mode 100644 tests/baselines/reference/textChanges/deleteRange1.js create mode 100644 tests/baselines/reference/textChanges/extractMethodLike.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter3.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter4.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfterInClass1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfterInClass2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAt1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAt2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeBefore1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeBefore2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter10.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter11.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter12.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter13.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter14.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter15.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter16.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter17.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter18.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter3.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter4.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter5.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter6.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter7.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter8.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter9.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInStatementListAfterNodeWithoutSeparator1.js create mode 100644 tests/baselines/reference/textChanges/replaceNode1.js create mode 100644 tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js create mode 100644 tests/baselines/reference/textChanges/replaceNode2.js create mode 100644 tests/baselines/reference/textChanges/replaceNode3.js create mode 100644 tests/baselines/reference/textChanges/replaceNode4.js create mode 100644 tests/baselines/reference/textChanges/replaceNode5.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange1.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange2.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange3.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange4.js create mode 100644 tests/baselines/reference/textChanges/replaceRange.js create mode 100644 tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js create mode 100644 tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js diff --git a/Jakefile.js b/Jakefile.js index 595875dfc32..2df29911125 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -11,11 +11,7 @@ var ts = require("./lib/typescript"); // Variables var compilerDirectory = "src/compiler/"; -var servicesDirectory = "src/services/"; var serverDirectory = "src/server/"; -var typingsInstallerDirectory = "src/server/typingsInstaller"; -var cancellationTokenDirectory = "src/server/cancellationToken"; -var watchGuardDirectory = "src/server/watchGuard"; var harnessDirectory = "src/harness/"; var libraryDirectory = "src/lib/"; var scriptsDirectory = "scripts/"; @@ -131,6 +127,7 @@ var harnessSources = harnessCoreSources.concat([ "matchFiles.ts", "initializeTSConfig.ts", "printer.ts", + "textChanges.ts", "transform.ts", "customTransforms.ts", ].map(function (f) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b10f2e7cb17..616be35270e 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -199,6 +199,8 @@ namespace ts { onEmitHelpers, onSetSourceFile, substituteNode, + onBeforeEmitNodeArray, + onAfterEmitNodeArray } = handlers; const newLine = getNewLineCharacter(printerOptions); @@ -631,6 +633,11 @@ namespace ts { if (isExpression(node)) { return pipelineEmitExpression(trySubstituteNode(EmitHint.Expression, node)); } + + if (isToken(node)) { + writeTokenText(kind); + return; + } } function pipelineEmitExpression(node: Node): void { @@ -1553,6 +1560,10 @@ namespace ts { emitSignatureAndBody(node, emitSignatureHead); } + function emitBlockCallback(_hint: EmitHint, body: Node): void { + emitBlockFunctionBody(body); + } + function emitSignatureAndBody(node: FunctionLikeDeclaration, emitSignatureHead: (node: SignatureDeclaration) => void) { const body = node.body; if (body) { @@ -1564,12 +1575,22 @@ namespace ts { if (getEmitFlags(node) & EmitFlags.ReuseTempVariableScope) { emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(EmitHint.Unspecified, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } } else { pushNameGenerationScope(); emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(EmitHint.Unspecified, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } popNameGenerationScope(); } @@ -2200,6 +2221,10 @@ namespace ts { write(getOpeningBracket(format)); } + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (isEmpty) { // Write a line terminator if the parent node was multi-line if (format & ListFormat.MultiLine) { @@ -2315,6 +2340,10 @@ namespace ts { } } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } + if (format & ListFormat.BracketsMask) { write(getClosingBracket(format)); } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 3ff3bc2782f..669c66c4337 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1099,6 +1099,10 @@ namespace ts { : node; } + export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode { + return createSynthesizedNode(kind); + } + export function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.FunctionDeclaration); node.decorators = asNodeArray(decorators); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index fb91b0ff5b7..b7a3f35d728 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -333,7 +333,7 @@ namespace ts { } /* @internal */ - export function getLineStarts(sourceFile: SourceFile): number[] { + export function getLineStarts(sourceFile: SourceFileLike): number[] { return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 97b12aeb712..86895f3db6e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2205,6 +2205,16 @@ namespace ts { name: string; } + /* @internal */ + /** + * Subset of properties from SourceFile that are used in multiple utility functions + */ + export interface SourceFileLike { + readonly text: string; + lineMap: number[]; + } + + // Source files are declarations when they are external modules. export interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; @@ -4132,6 +4142,8 @@ namespace ts { /*@internal*/ onEmitSourceMapOfPosition?: (pos: number) => void; /*@internal*/ onEmitHelpers?: (node: Node, writeLines: (text: string) => void) => void; /*@internal*/ onSetSourceFile?: (node: SourceFile) => void; + /*@internal*/ onBeforeEmitNodeArray?: (nodes: NodeArray) => void; + /*@internal*/ onAfterEmitNodeArray?: (nodes: NodeArray) => void; } export interface PrinterOptions { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a5229b614be..030b66813a5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -184,7 +184,7 @@ namespace ts { return false; } - export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number { + export function getStartPositionOfLine(line: number, sourceFile: SourceFileLike): number { Debug.assert(line >= 0); return getLineStarts(sourceFile)[line]; } @@ -204,7 +204,7 @@ namespace ts { return value !== undefined; } - export function getEndLinePosition(line: number, sourceFile: SourceFile): number { + export function getEndLinePosition(line: number, sourceFile: SourceFileLike): number { Debug.assert(line >= 0); const lineStarts = getLineStarts(sourceFile); @@ -255,7 +255,11 @@ namespace ts { return !nodeIsMissing(node); } - export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDoc?: boolean): number { + export function isToken(n: Node): boolean { + return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; + } + + export function getTokenPosOfNode(node: Node, sourceFile?: SourceFileLike, includeJsDoc?: boolean): number { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. if (nodeIsMissing(node)) { @@ -289,7 +293,7 @@ namespace ts { return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; } - export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number { + export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number { if (nodeIsMissing(node) || !node.decorators) { return getTokenPosOfNode(node, sourceFile); } @@ -2491,7 +2495,7 @@ namespace ts { return indentStrings[1].length; } - export function createTextWriter(newLine: String): EmitTextWriter { + export function createTextWriter(newLine: string): EmitTextWriter { let output: string; let indent: number; let lineStart: boolean; diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 0f4a4ed6561..133c62e1926 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -154,9 +154,9 @@ namespace ts { * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - export function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext) { + export function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes) { context.startLexicalEnvironment(); - const updated = visitNodes(nodes, visitor, isParameterDeclaration); + const updated = nodesVisitor(nodes, visitor, isParameterDeclaration); context.suspendLexicalEnvironment(); return updated; } @@ -204,9 +204,9 @@ namespace ts { * @param visitor The callback used to visit each child. * @param context A lexical environment context for the visitor. */ - export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext): T | undefined; + export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): T | undefined; - export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext): Node { + export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes): Node { if (node === undefined) { return undefined; } @@ -243,8 +243,8 @@ namespace ts { // Signature elements case SyntaxKind.Parameter: return updateParameter(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), (node).dotDotDotToken, visitNode((node).name, visitor, isBindingName), visitNode((node).type, visitor, isTypeNode), @@ -257,55 +257,55 @@ namespace ts { // Type member case SyntaxKind.PropertyDeclaration: return updateProperty(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), visitNode((node).type, visitor, isTypeNode), visitNode((node).initializer, visitor, isExpression)); case SyntaxKind.MethodDeclaration: return updateMethod(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), (node).asteriskToken, visitNode((node).name, visitor, isPropertyName), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.Constructor: return updateConstructor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.GetAccessor: return updateGetAccessor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), - visitParameterList((node).parameters, visitor, context), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.SetAccessor: return updateSetAccessor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), - visitParameterList((node).parameters, visitor, context), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitFunctionBody((node).body, visitor, context)); // Binding patterns case SyntaxKind.ObjectBindingPattern: return updateObjectBindingPattern(node, - visitNodes((node).elements, visitor, isBindingElement)); + nodesVisitor((node).elements, visitor, isBindingElement)); case SyntaxKind.ArrayBindingPattern: return updateArrayBindingPattern(node, - visitNodes((node).elements, visitor, isArrayBindingElement)); + nodesVisitor((node).elements, visitor, isArrayBindingElement)); case SyntaxKind.BindingElement: return updateBindingElement(node, @@ -317,11 +317,11 @@ namespace ts { // Expression case SyntaxKind.ArrayLiteralExpression: return updateArrayLiteral(node, - visitNodes((node).elements, visitor, isExpression)); + nodesVisitor((node).elements, visitor, isExpression)); case SyntaxKind.ObjectLiteralExpression: return updateObjectLiteral(node, - visitNodes((node).properties, visitor, isObjectLiteralElementLike)); + nodesVisitor((node).properties, visitor, isObjectLiteralElementLike)); case SyntaxKind.PropertyAccessExpression: return updatePropertyAccess(node, @@ -336,14 +336,14 @@ namespace ts { case SyntaxKind.CallExpression: return updateCall(node, visitNode((node).expression, visitor, isExpression), - visitNodes((node).typeArguments, visitor, isTypeNode), - visitNodes((node).arguments, visitor, isExpression)); + nodesVisitor((node).typeArguments, visitor, isTypeNode), + nodesVisitor((node).arguments, visitor, isExpression)); case SyntaxKind.NewExpression: return updateNew(node, visitNode((node).expression, visitor, isExpression), - visitNodes((node).typeArguments, visitor, isTypeNode), - visitNodes((node).arguments, visitor, isExpression)); + nodesVisitor((node).typeArguments, visitor, isTypeNode), + nodesVisitor((node).arguments, visitor, isExpression)); case SyntaxKind.TaggedTemplateExpression: return updateTaggedTemplate(node, @@ -361,19 +361,19 @@ namespace ts { case SyntaxKind.FunctionExpression: return updateFunctionExpression(node, - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).modifiers, visitor, isModifier), (node).asteriskToken, visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.ArrowFunction: return updateArrowFunction(node, - visitNodes((node).modifiers, visitor, isModifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).modifiers, visitor, isModifier), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); @@ -415,7 +415,7 @@ namespace ts { case SyntaxKind.TemplateExpression: return updateTemplateExpression(node, visitNode((node).head, visitor, isTemplateHead), - visitNodes((node).templateSpans, visitor, isTemplateSpan)); + nodesVisitor((node).templateSpans, visitor, isTemplateSpan)); case SyntaxKind.YieldExpression: return updateYield(node, @@ -428,15 +428,15 @@ namespace ts { case SyntaxKind.ClassExpression: return updateClassExpression(node, - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitNodes((node).heritageClauses, visitor, isHeritageClause), - visitNodes((node).members, visitor, isClassElement)); + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).heritageClauses, visitor, isHeritageClause), + nodesVisitor((node).members, visitor, isClassElement)); case SyntaxKind.ExpressionWithTypeArguments: return updateExpressionWithTypeArguments(node, - visitNodes((node).typeArguments, visitor, isTypeNode), + nodesVisitor((node).typeArguments, visitor, isTypeNode), visitNode((node).expression, visitor, isExpression)); case SyntaxKind.AsExpression: @@ -457,11 +457,11 @@ namespace ts { // Element case SyntaxKind.Block: return updateBlock(node, - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.VariableStatement: return updateVariableStatement(node, - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).declarationList, visitor, isVariableDeclarationList)); case SyntaxKind.ExpressionStatement: @@ -549,61 +549,61 @@ namespace ts { case SyntaxKind.VariableDeclarationList: return updateVariableDeclarationList(node, - visitNodes((node).declarations, visitor, isVariableDeclaration)); + nodesVisitor((node).declarations, visitor, isVariableDeclaration)); case SyntaxKind.FunctionDeclaration: return updateFunctionDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), (node).asteriskToken, visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.ClassDeclaration: return updateClassDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitNodes((node).heritageClauses, visitor, isHeritageClause), - visitNodes((node).members, visitor, isClassElement)); + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).heritageClauses, visitor, isHeritageClause), + nodesVisitor((node).members, visitor, isClassElement)); case SyntaxKind.EnumDeclaration: return updateEnumDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), - visitNodes((node).members, visitor, isEnumMember)); + nodesVisitor((node).members, visitor, isEnumMember)); case SyntaxKind.ModuleDeclaration: return updateModuleDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), visitNode((node).body, visitor, isModuleBody)); case SyntaxKind.ModuleBlock: return updateModuleBlock(node, - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.CaseBlock: return updateCaseBlock(node, - visitNodes((node).clauses, visitor, isCaseOrDefaultClause)); + nodesVisitor((node).clauses, visitor, isCaseOrDefaultClause)); case SyntaxKind.ImportEqualsDeclaration: return updateImportEqualsDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), visitNode((node).moduleReference, visitor, isModuleReference)); case SyntaxKind.ImportDeclaration: return updateImportDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).importClause, visitor, isImportClause), visitNode((node).moduleSpecifier, visitor, isExpression)); @@ -618,7 +618,7 @@ namespace ts { case SyntaxKind.NamedImports: return updateNamedImports(node, - visitNodes((node).elements, visitor, isImportSpecifier)); + nodesVisitor((node).elements, visitor, isImportSpecifier)); case SyntaxKind.ImportSpecifier: return updateImportSpecifier(node, @@ -627,20 +627,20 @@ namespace ts { case SyntaxKind.ExportAssignment: return updateExportAssignment(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).expression, visitor, isExpression)); case SyntaxKind.ExportDeclaration: return updateExportDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).exportClause, visitor, isNamedExports), visitNode((node).moduleSpecifier, visitor, isExpression)); case SyntaxKind.NamedExports: return updateNamedExports(node, - visitNodes((node).elements, visitor, isExportSpecifier)); + nodesVisitor((node).elements, visitor, isExportSpecifier)); case SyntaxKind.ExportSpecifier: return updateExportSpecifier(node, @@ -656,12 +656,12 @@ namespace ts { case SyntaxKind.JsxElement: return updateJsxElement(node, visitNode((node).openingElement, visitor, isJsxOpeningElement), - visitNodes((node).children, visitor, isJsxChild), + nodesVisitor((node).children, visitor, isJsxChild), visitNode((node).closingElement, visitor, isJsxClosingElement)); case SyntaxKind.JsxAttributes: return updateJsxAttributes(node, - visitNodes((node).properties, visitor, isJsxAttributeLike)); + nodesVisitor((node).properties, visitor, isJsxAttributeLike)); case SyntaxKind.JsxSelfClosingElement: return updateJsxSelfClosingElement(node, @@ -694,15 +694,15 @@ namespace ts { case SyntaxKind.CaseClause: return updateCaseClause(node, visitNode((node).expression, visitor, isExpression), - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.DefaultClause: return updateDefaultClause(node, - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.HeritageClause: return updateHeritageClause(node, - visitNodes((node).types, visitor, isExpressionWithTypeArguments)); + nodesVisitor((node).types, visitor, isExpressionWithTypeArguments)); case SyntaxKind.CatchClause: return updateCatchClause(node, diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 35788ebca80..d7638ffc033 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -22,6 +22,10 @@ namespace FourSlash { ts.disableIncrementalParsing = false; + function normalizeNewLines(s: string) { + return s.replace(/\r\n/g, "\n"); + } + // Represents a parsed source file with metadata export interface FourSlashFile { // The contents of the file (with markers, etc stripped out) @@ -1958,8 +1962,7 @@ namespace FourSlash { public verifyCurrentFileContent(text: string) { const actual = this.getFileContent(this.activeFile.fileName); - const replaceNewlines = (str: string) => str.replace(/\r\n/g, "\n"); - if (replaceNewlines(actual) !== replaceNewlines(text)) { + if (normalizeNewLines(actual) !== normalizeNewLines(text)) { throw new Error("verifyCurrentFileContent\n" + "\tExpected: \"" + text + "\"\n" + "\t Actual: \"" + actual + "\""); @@ -2135,7 +2138,7 @@ namespace FourSlash { const actualText = this.rangeText(ranges[0]); const result = includeWhiteSpace - ? actualText === expectedText + ? normalizeNewLines(actualText) === normalizeNewLines(expectedText) : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText); if (!result) { @@ -2185,7 +2188,7 @@ namespace FourSlash { continue; } - const newActions = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]); + const newActions = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code], this.formatCodeSettings); if (newActions && newActions.length) { actions = actions ? actions.concat(newActions) : newActions; } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 21622325368..1bbdfa71280 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -125,6 +125,7 @@ "./unittests/projectErrors.ts", "./unittests/printer.ts", "./unittests/transform.ts", - "./unittests/customTransforms.ts" + "./unittests/customTransforms.ts", + "./unittests/textChanges.ts" ] } diff --git a/src/harness/unittests/textChanges.ts b/src/harness/unittests/textChanges.ts new file mode 100644 index 00000000000..8269b6de6be --- /dev/null +++ b/src/harness/unittests/textChanges.ts @@ -0,0 +1,791 @@ +/// +/// +/// + +namespace ts { + describe("textChanges", () => { + function findChild(name: string, n: Node) { + return find(n); + + function find(node: Node): Node { + if (isDeclaration(node) && node.name && isIdentifier(node.name) && node.name.text === name) { + return node; + } + else { + return forEachChild(node, find); + } + } + } + + const printerOptions = { newLine: NewLineKind.LineFeed }; + const newLineCharacter = getNewLineCharacter(printerOptions); + + function getRuleProvider(action?: (opts: FormatCodeSettings) => void) { + const options = { + indentSize: 4, + tabSize: 4, + newLineCharacter, + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + if (action) { + action(options); + } + const rulesProvider = new formatting.RulesProvider(); + rulesProvider.ensureUpToDate(options); + return rulesProvider; + } + + // validate that positions that were recovered from the printed text actually match positions that will be created if the same text is parsed. + function verifyPositions({ text, node }: textChanges.NonFormattedText): void { + const nodeList = flattenNodes(node); + const sourceFile = createSourceFile("f.ts", text, ScriptTarget.ES2015); + const parsedNodeList = flattenNodes(sourceFile.statements[0]); + Debug.assert(nodeList.length === parsedNodeList.length); + for (let i = 0; i < nodeList.length; i++) { + const left = nodeList[i]; + const right = parsedNodeList[i]; + Debug.assert(left.pos === right.pos); + Debug.assert(left.end === right.end); + } + + function flattenNodes(n: Node) { + const data: (Node | NodeArray)[] = []; + walk(n); + return data; + + function walk(n: Node | Node[]): void { + data.push(n); + return isArray(n) ? forEach(n, walk) : forEachChild(n, walk, walk); + } + } + } + + function runSingleFileTest(caption: string, setupFormatOptions: (opts: FormatCodeSettings) => void, text: string, validateNodes: boolean, testBlock: (sourceFile: SourceFile, changeTracker: textChanges.ChangeTracker) => void) { + it(caption, () => { + Harness.Baseline.runBaseline(`textChanges/${caption}.js`, () => { + const sourceFile = createSourceFile("source.ts", text, ScriptTarget.ES2015, /*setParentNodes*/ true); + const rulesProvider = getRuleProvider(setupFormatOptions); + const changeTracker = new textChanges.ChangeTracker(printerOptions.newLine, rulesProvider, validateNodes ? verifyPositions : undefined); + testBlock(sourceFile, changeTracker); + const changes = changeTracker.getChanges(); + assert.equal(changes.length, 1); + assert.equal(changes[0].fileName, sourceFile.fileName); + const modified = textChanges.applyChanges(sourceFile.text, changes[0].textChanges); + return `===ORIGINAL===${newLineCharacter}${text}${newLineCharacter}===MODIFIED===${newLineCharacter}${modified}`; + }); + }); + } + + function setNewLineForOpenBraceInFunctions(opts: FormatCodeSettings) { + opts.placeOpenBraceOnNewLineForFunctions = true; + } + + { + const text = ` +namespace M +{ + namespace M2 + { + function foo() { + // comment 1 + const x = 1; + + /** + * comment 2 line 1 + * comment 2 line 2 + */ + function f() { + return 100; + } + const y = 2; // comment 3 + return 1; + } + } +}`; + runSingleFileTest("extractMethodLike", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + const statements = ((findChild("foo", sourceFile)).body).statements.slice(1); + const newFunction = createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ "bar", + /*typeParameters*/ undefined, + /*parameters*/ emptyArray, + /*type*/ createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*body */ createBlock(statements) + ); + + changeTracker.insertNodeBefore(sourceFile, /*before*/findChild("M2", sourceFile), newFunction, { suffix: newLineCharacter }); + + // replace statements with return statement + const newStatement = createReturn( + createCall( + /*expression*/ newFunction.name, + /*typeArguments*/ undefined, + /*argumentsArray*/ emptyArray + )); + changeTracker.replaceNodeRange(sourceFile, statements[0], lastOrUndefined(statements), newStatement, { suffix: newLineCharacter }); + }); + } + { + const text = ` +function foo() { + return 1; +} + +function bar() { + return 2; +} +`; + runSingleFileTest("deleteRange1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteRange(sourceFile, { pos: text.indexOf("function foo"), end: text.indexOf("function bar") }); + }); + } + function findVariableStatementContaining(name: string, sourceFile: SourceFile) { + const varDecl = findChild(name, sourceFile); + assert.equal(varDecl.kind, SyntaxKind.VariableDeclaration); + const varStatement = varDecl.parent.parent; + assert.equal(varStatement.kind, SyntaxKind.VariableStatement); + return varStatement; + } + { + const text = ` +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 +`; + runSingleFileTest("deleteNode1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile)); + }); + runSingleFileTest("deleteNode2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true }); + }); + runSingleFileTest("deleteNode3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("deleteNode4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("deleteNode5", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("x", sourceFile)); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +`; + runSingleFileTest("deleteNodeRange1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile)); + }); + runSingleFileTest("deleteNodeRange2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), + { useNonAdjustedStartPosition: true }); + }); + runSingleFileTest("deleteNodeRange3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), + { useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("deleteNodeRange4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), + { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + } + function createTestVariableDeclaration(name: string) { + return createVariableDeclaration(name, /*type*/ undefined, createObjectLiteral([createPropertyAssignment("p1", createLiteral(1))], /*multiline*/ true)); + } + function createTestClass() { + return createClassDeclaration( + /*decorators*/ undefined, + [ + createToken(SyntaxKind.PublicKeyword) + ], + "class1", + /*typeParameters*/ undefined, + [ + createHeritageClause( + SyntaxKind.ImplementsKeyword, + [ + createExpressionWithTypeArguments(/*typeArguments*/ undefined, createIdentifier("interface1")) + ] + ) + ], + [ + createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + "property1", + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.BooleanKeyword), + /*initializer*/ undefined + ) + ] + ); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("replaceRange", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("replaceRangeWithForcedIndentation", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { suffix: newLineCharacter, indentation: 8, delta: 0 }); + }); + + runSingleFileTest("replaceRangeNoLineBreakBefore", setNewLineForOpenBraceInFunctions, `const x = 1, y = "2";`, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createTestVariableDeclaration("z1"); + changeTracker.replaceRange(sourceFile, { pos: sourceFile.text.indexOf("y"), end: sourceFile.text.indexOf(";") }, newNode); + }); + } + { + const text = ` +namespace A { + const x = 1, y = "2"; +} +`; + runSingleFileTest("replaceNode1NoLineBreakBefore", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createTestVariableDeclaration("z1"); + changeTracker.replaceNode(sourceFile, findChild("y", sourceFile), newNode); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("replaceNode1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("replaceNode2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, suffix: newLineCharacter, prefix: newLineCharacter }); + }); + runSingleFileTest("replaceNode3", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, suffix: newLineCharacter }); + }); + runSingleFileTest("replaceNode4", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("replaceNode5", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("x", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("replaceNodeRange1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("replaceNodeRange2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, suffix: newLineCharacter, prefix: newLineCharacter }); + }); + runSingleFileTest("replaceNodeRange3", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, suffix: newLineCharacter }); + }); + runSingleFileTest("replaceNodeRange4", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("insertNodeAt1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeAt(sourceFile, text.indexOf("var y"), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("insertNodeAt2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAt(sourceFile, text.indexOf("; // comment 4"), createTestVariableDeclaration("z1")); + }); + } + { + const text = ` +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +}`; + runSingleFileTest("insertNodeBefore1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeBefore(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("insertNodeBefore2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeBefore(sourceFile, findChild("M", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("insertNodeAfter1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("insertNodeAfter2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findChild("M", sourceFile), createTestClass(), { prefix: newLineCharacter }); + }); + } + { + function findOpenBraceForConstructor(sourceFile: SourceFile) { + const classDecl = sourceFile.statements[0]; + const constructorDecl = forEach(classDecl.members, m => m.kind === SyntaxKind.Constructor && (m).body && m); + return constructorDecl.body.getFirstToken(); + } + function createTestSuperCall() { + const superCall = createCall( + createSuper(), + /*typeArguments*/ undefined, + /*argumentsArray*/ emptyArray + ); + return createStatement(superCall); + } + const text1 = ` +class A { + constructor() { + } +} +`; + runSingleFileTest("insertNodeAfter3", noop, text1, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { suffix: newLineCharacter }); + }); + const text2 = ` +class A { + constructor() { + var x = 1; + } +} +`; + runSingleFileTest("insertNodeAfter4", noop, text2, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), createTestSuperCall(), { suffix: newLineCharacter }); + }); + const text3 = ` +class A { + constructor() { + + } +} +`; + runSingleFileTest("insertNodeAfter3-block with newline", noop, text3, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { suffix: newLineCharacter }); + }); + } + { + const text = `var a = 1, b = 2, c = 3;`; + runSingleFileTest("deleteNodeInList1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = `var a = 1,b = 2,c = 3;`; + runSingleFileTest("deleteNodeInList1_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList2_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList3_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +namespace M { + var a = 1, + b = 2, + c = 3; +}`; + runSingleFileTest("deleteNodeInList4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList5", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList6", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +}`; + runSingleFileTest("deleteNodeInList4_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList5_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList6_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +function foo(a: number, b: string, c = true) { + return 1; +}`; + runSingleFileTest("deleteNodeInList7", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList8", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList9", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +function foo(a: number,b: string,c = true) { + return 1; +}`; + runSingleFileTest("deleteNodeInList10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +function foo( + a: number, + b: string, + c = true) { + return 1; +}`; + runSingleFileTest("deleteNodeInList13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +const x = 1, y = 2;`; + runSingleFileTest("insertNodeInListAfter1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const /*x*/ x = 1, /*y*/ y = 2;`; + runSingleFileTest("insertNodeInListAfter3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const x = 1;`; + runSingleFileTest("insertNodeInListAfter5", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const x = 1, + y = 2;`; + runSingleFileTest("insertNodeInListAfter6", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter7", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const /*x*/ x = 1, + /*y*/ y = 2;`; + runSingleFileTest("insertNodeInListAfter8", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter9", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +import { + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter16", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter17", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter18", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +class A { + x; +}`; + runSingleFileTest("insertNodeAfterMultipleNodes", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + let newNodes = []; + for (let i = 0; i < 11 /*error doesn't occur with fewer nodes*/; ++i) { + newNodes.push( + createProperty(undefined, undefined, i + "", undefined, undefined, undefined)); + } + const insertAfter = findChild("x", sourceFile); + for (const newNode of newNodes) { + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: newLineCharacter }); + } + }); + } + { + const text = ` +class A { + x +} +`; + runSingleFileTest("insertNodeAfterInClass1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), createProperty(undefined, undefined, "a", undefined, createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined), { suffix: newLineCharacter }); + }); + } + { + const text = ` +class A { + x; +} +`; + runSingleFileTest("insertNodeAfterInClass2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), createProperty(undefined, undefined, "a", undefined, createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined), { suffix: newLineCharacter }); + }); + } + { + const text = ` +class A { + x; + y = 1; +} +`; + runSingleFileTest("deleteNodeAfterInClass1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findChild("x", sourceFile)); + }); + } + { + const text = ` +class A { + x + y = 1; +} +`; + runSingleFileTest("deleteNodeAfterInClass2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findChild("x", sourceFile)); + }); + } + { + const text = ` +class A { + x = foo +} +` + runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createComputedPropertyName(createLiteral(1)), + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*initializer*/ undefined); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + { + const text = ` +class A { + x() { + } +} +` + runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createComputedPropertyName(createLiteral(1)), + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*initializer*/ undefined); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + { + const text = ` +interface A { + x +} +` + runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createComputedPropertyName(createLiteral(1)), + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*initializer*/ undefined); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + { + const text = ` +interface A { + x() +} +` + runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createComputedPropertyName(createLiteral(1)), + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*initializer*/ undefined); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + { + const text = ` +let x = foo +` + runSingleFileTest("insertNodeInStatementListAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createStatement(createParen(createLiteral(1))); + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + }); +} \ No newline at end of file diff --git a/src/server/session.ts b/src/server/session.ts index b5e7e44970d..64fce61a095 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1420,8 +1420,9 @@ namespace ts.server { const scriptInfo = project.getScriptInfoForNormalizedPath(file); const startPosition = getStartPosition(); const endPosition = getEndPosition(); + const formatOptions = this.projectService.getFormatCodeOptions(file); - const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, formatOptions); if (!codeActions) { return undefined; } diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index c22ba779d19..bab5356e99c 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -13,6 +13,7 @@ namespace ts { newLineCharacter: string; host: LanguageServiceHost; cancellationToken: CancellationToken; + rulesProvider: formatting.RulesProvider; } export namespace codefix { diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 4528c48774d..6d7efb64c6f 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -26,22 +26,13 @@ namespace ts.codefix { } } } - - const newPosition = getOpenBraceEnd(constructor, sourceFile); - const changes = [{ - fileName: sourceFile.fileName, textChanges: [{ - newText: superCall.getText(sourceFile), - span: { start: newPosition, length: 0 } - }, - { - newText: "", - span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } - }] - }]; + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.insertNodeAfter(sourceFile, getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); + changeTracker.deleteNode(sourceFile, superCall); return [{ description: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), - changes + changes: changeTracker.getChanges() }]; function findSuperCall(n: Node): ExpressionStatement { diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts index 0dede87cf28..822c34842fd 100644 --- a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -10,10 +10,13 @@ namespace ts.codefix { return undefined; } - const newPosition = getOpenBraceEnd(token.parent, sourceFile); + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const superCall = createStatement(createCall(createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ emptyArray)); + changeTracker.insertNodeAfter(sourceFile, getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); + return [{ description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); diff --git a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts index 1e72700ec01..80d4345a943 100644 --- a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts +++ b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts @@ -21,26 +21,20 @@ namespace ts.codefix { return undefined; } - let changeStart = extendsToken.getStart(sourceFile); - let changeEnd = extendsToken.getEnd(); - const textChanges: TextChange[] = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, extendsToken, createToken(SyntaxKind.ImplementsKeyword)); // We replace existing keywords with commas. for (let i = 1; i < heritageClauses.length; i++) { const keywordToken = heritageClauses[i].getFirstToken(); if (keywordToken) { - changeStart = keywordToken.getStart(sourceFile); - changeEnd = keywordToken.getEnd(); - textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + changeTracker.replaceNode(sourceFile, keywordToken, createToken(SyntaxKind.CommaToken)); } } const result = [{ description: getLocaleSpecificMessage(Diagnostics.Change_extends_to_implements), - changes: [{ - fileName: sourceFile.fileName, - textChanges: textChanges - }] + changes: changeTracker.getChanges() }]; return result; diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts index c9d59dd8337..711a3289a27 100644 --- a/src/services/codefixes/fixForgottenThisPropertyAccess.ts +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -5,11 +5,15 @@ namespace ts.codefix { getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); - const start = token.getStart(sourceFile); + if (token.kind !== SyntaxKind.Identifier) { + return undefined; + } + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, token, createPropertyAccess(createThis(), token)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_this_to_unresolved_variable), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 3e07efbc3de..743c13ccf38 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -130,7 +130,7 @@ namespace ts.codefix { // this is a module id -> module import declaration map const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; - let cachedNewImportInsertPosition: number; + let lastImportDeclaration: Node; const currentTokenMeaning = getMeaningFromLocation(token); if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { @@ -138,14 +138,14 @@ namespace ts.codefix { return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); } - const allPotentialModules = checker.getAmbientModules(); + const candidateModules = checker.getAmbientModules(); for (const otherSourceFile of allSourceFiles) { if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) { - allPotentialModules.push(otherSourceFile.symbol); + candidateModules.push(otherSourceFile.symbol); } } - for (const moduleSymbol of allPotentialModules) { + for (const moduleSymbol of candidateModules) { context.cancellationToken.throwIfCancellationRequested(); // check the default export @@ -277,14 +277,12 @@ namespace ts.codefix { * If the existing import declaration already has a named import list, just * insert the identifier into that list. */ - const textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); + const fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause); const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); actions.push(createCodeAction( Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], - textChange.newText, - textChange.span, - sourceFile.fileName, + fileTextChanges, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes )); @@ -302,49 +300,31 @@ namespace ts.codefix { return declaration.moduleReference.getText(); } - function getTextChangeForImportClause(importClause: ImportClause): TextChange { - const newImportText = isDefault ? `default as ${name}` : name; + function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] { + //const newImportText = isDefault ? `default as ${name}` : name; const importList = importClause.namedBindings; + const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name)); // case 1: // original text: import default from "module" // change to: import default, { name } from "module" - if (!importList && importClause.name) { - const start = importClause.name.getEnd(); - return { - newText: `, { ${newImportText} }`, - span: { start, length: 0 } - }; - } - // case 2: // original text: import {} from "module" // change to: import { name } from "module" - if (importList.elements.length === 0) { - const start = importList.getStart(); - return { - newText: `{ ${newImportText} }`, - span: { start, length: importList.getEnd() - start } - }; + if (!importList || importList.elements.length === 0) { + const newImportClause = createImportClause(importClause.name, createNamedImports([newImportSpecifier])); + return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges(); } - // case 3: - // original text: import { foo, bar } from "module" - // change to: import { foo, bar, name } from "module" - const insertPoint = importList.elements[importList.elements.length - 1].getEnd(); /** * If the import list has one import per line, preserve that. Otherwise, insert on same line as last element * import { * foo * } from "./module"; */ - const startLine = getLineOfLocalPosition(sourceFile, importList.getStart()); - const endLine = getLineOfLocalPosition(sourceFile, importList.getEnd()); - const oneImportPerLine = endLine - startLine > importList.elements.length; - - return { - newText: `,${oneImportPerLine ? context.newLineCharacter : " "}${newImportText}`, - span: { start: insertPoint, length: 0 } - }; + return createChangeTracker().insertNodeInListAfter( + sourceFile, + importList.elements[importList.elements.length - 1], + newImportSpecifier).getChanges(); } function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction { @@ -370,48 +350,47 @@ namespace ts.codefix { return createCodeAction( Diagnostics.Change_0_to_1, [name, `${namespacePrefix}.${name}`], - `${namespacePrefix}.`, - { start: token.getStart(), length: 0 }, - sourceFile.fileName, + createChangeTracker().replaceNode(sourceFile, token, createPropertyAccess(createIdentifier(namespacePrefix), name)).getChanges(), "CodeChange" ); } } function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction { - if (!cachedNewImportInsertPosition) { + if (!lastImportDeclaration) { // insert after any existing imports - let lastModuleSpecifierEnd = -1; - for (const moduleSpecifier of sourceFile.imports) { - const end = moduleSpecifier.getEnd(); - if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { - lastModuleSpecifierEnd = end; + for (let i = sourceFile.statements.length - 1; i >= 0; i--) { + const statement = sourceFile.statements[i]; + if (statement.kind === SyntaxKind.ImportEqualsDeclaration || statement.kind === SyntaxKind.ImportDeclaration) { + lastImportDeclaration = statement; + break; } } - cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); } const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); - const importStatementText = isDefault - ? `import ${name} from "${moduleSpecifierWithoutQuotes}"` + const changeTracker = createChangeTracker(); + const importClause = isDefault + ? createImportClause(createIdentifier(name), /*namedBindings*/ undefined) : isNamespaceImport - ? `import * as ${name} from "${moduleSpecifierWithoutQuotes}"` - : `import { ${name} } from "${moduleSpecifierWithoutQuotes}"`; + ? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(name))) + : createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))])); + const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, createLiteral(moduleSpecifierWithoutQuotes)); + if (!lastImportDeclaration) { + changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: `${context.newLineCharacter}${context.newLineCharacter}` }); + } + else { + changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); + } // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. - const newText = cachedNewImportInsertPosition === sourceFile.getStart() - ? `${importStatementText};${context.newLineCharacter}${context.newLineCharacter}` - : `${context.newLineCharacter}${importStatementText};`; - return createCodeAction( Diagnostics.Import_0_from_1, [name, `"${moduleSpecifierWithoutQuotes}"`], - newText, - { start: cachedNewImportInsertPosition, length: 0 }, - sourceFile.fileName, + changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes ); @@ -576,17 +555,19 @@ namespace ts.codefix { } + function createChangeTracker() { + return textChanges.ChangeTracker.fromCodeFixContext(context);; + } + function createCodeAction( description: DiagnosticMessage, diagnosticArgs: string[], - newText: string, - span: TextSpan, - fileName: string, + changes: FileTextChanges[], kind: ImportCodeActionKind, moduleSpecifier?: string): ImportCodeAction { return { description: formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), - changes: [{ fileName, textChanges: [{ newText, span }] }], + changes, kind, moduleSpecifier }; diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 61d48bdc3bc..f77f9723d0f 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -25,17 +25,17 @@ namespace ts.codefix { const forStatement = token.parent.parent.parent; const forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFixToRemoveNode(forInitializer); + return deleteNode(forInitializer); } else { - return removeSingleItem(forInitializer.declarations, token); + return deleteNodeInList(token.parent); } case SyntaxKind.ForOfStatement: const forOfStatement = token.parent.parent.parent; if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { const forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + return replaceNode(forOfInitializer.declarations[0], createObjectLiteral()); } break; @@ -47,51 +47,59 @@ namespace ts.codefix { case SyntaxKind.CatchClause: const catchClause = token.parent.parent; const parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFixToRemoveNode(parameter); + return deleteNode(parameter); default: const variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFixToRemoveNode(variableStatement); + return deleteNode(variableStatement); } else { - const declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); + return deleteNodeInList(token.parent); } } case SyntaxKind.TypeParameter: const typeParameters = (token.parent.parent).typeParameters; if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1); + if (!previousToken || previousToken.kind !== SyntaxKind.LessThanToken) { + return deleteRange(typeParameters); + } + const nextToken = getTokenAtPosition(sourceFile, typeParameters.end); + if (!nextToken || nextToken.kind !== SyntaxKind.GreaterThanToken) { + return deleteRange(typeParameters); + } + return deleteNodeRange(previousToken, nextToken); } else { - return removeSingleItem(typeParameters, token); + return deleteNodeInList(token.parent); } case ts.SyntaxKind.Parameter: const functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else { - return removeSingleItem(functionDeclaration.parameters, token); + return deleteNodeInList(token.parent); } // handle case where 'import a = A;' case SyntaxKind.ImportEqualsDeclaration: - const importEquals = findImportDeclaration(token); - return createCodeFixToRemoveNode(importEquals); + const importEquals = getAncestor(token, SyntaxKind.ImportEqualsDeclaration); + return deleteNode(importEquals); case SyntaxKind.ImportSpecifier: const namedImports = token.parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. - const importSpec = findImportDeclaration(token); - return createCodeFixToRemoveNode(importSpec); + const importSpec = getAncestor(token, SyntaxKind.ImportDeclaration); + return deleteNode(importSpec); } else { - return removeSingleItem(namedImports.elements, token); + // delete import specifier + return deleteNodeInList(token.parent); } // handle case where "import d, * as ns from './file'" @@ -99,98 +107,79 @@ namespace ts.codefix { case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' const importClause = token.parent; if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| - const importDecl = findImportDeclaration(importClause); - return createCodeFixToRemoveNode(importDecl); + const importDecl = getAncestor(importClause, SyntaxKind.ImportDeclaration); + return deleteNode(importDecl); } else { // import |d,| * as ns from './file' - const start = importClause.name.getStart(); - let end = findFirstNonSpaceCharPosStarting(importClause.name.end); - if (sourceFile.text.charCodeAt(end) === CharacterCodes.comma) { - end = findFirstNonSpaceCharPosStarting(end + 1); + const start = importClause.name.getStart(sourceFile); + const nextToken = getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === SyntaxKind.CommaToken) { + // shift first non-whitespace position after comma to the start position of the node + return deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/true) }); + } + else { + return deleteNode(importClause.name); } - - return createCodeFix("", start, end - start); } case SyntaxKind.NamespaceImport: const namespaceImport = token.parent; if (namespaceImport.name == token && !(namespaceImport.parent).name) { - const importDecl = findImportDeclaration(namespaceImport); - return createCodeFixToRemoveNode(importDecl); + const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration); + return deleteNode(importDecl); } else { - const start = (namespaceImport.parent).name.end; - return createCodeFix("", start, (namespaceImport.parent).namedBindings.end - start); + const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1); + if (previousToken && previousToken.kind === SyntaxKind.CommaToken) { + const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart); + return deleteRange({ pos: startPosition, end: namespaceImport.end }); + } + return deleteRange(namespaceImport); } } break; case SyntaxKind.PropertyDeclaration: case SyntaxKind.NamespaceImport: - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } if (isDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else if (isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent.parent); + return deleteNode(token.parent.parent); } else { return undefined; } - function findImportDeclaration(token: Node): Node { - let importDecl = token; - while (importDecl.kind != SyntaxKind.ImportDeclaration && importDecl.parent) { - importDecl = importDecl.parent; - } - - return importDecl; + function deleteNode(n: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); } - function createCodeFixToRemoveNode(node: Node) { - let end = node.getEnd(); - const endCharCode = sourceFile.text.charCodeAt(end); - const afterEndCharCode = sourceFile.text.charCodeAt(end + 1); - if (isLineBreak(endCharCode)) { - end += 1; - } - // in the case of CR LF, you could have two consecutive new line characters for one new line. - // this needs to be differenciated from two LF LF chars that actually mean two new lines. - if (isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { - end += 1; - } - - const start = node.getStart(); - return createCodeFix("", start, end - start); + function deleteRange(range: TextRange) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); } - function findFirstNonSpaceCharPosStarting(start: number) { - while (isWhiteSpace(sourceFile.text.charCodeAt(start))) { - start += 1; - } - return start; + function deleteNodeInList(n: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); } - function createCodeFix(newText: string, start: number, length: number): CodeAction[] { + function deleteNodeRange(start: Node, end: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + } + + function replaceNode(n: Node, newNode: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + } + + function makeChange(changeTracker: textChanges.ChangeTracker) { return [{ description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText, span: { start, length } }] - }] + changes: changeTracker.getChanges() }]; } - - function removeSingleItem(elements: NodeArray, token: T): CodeAction[] { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); - } - else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); - } - } } }); } \ No newline at end of file diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 201d64e4d7e..4fa3b71a3a2 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -314,24 +314,55 @@ namespace ts.formatting { return 0; } + /* @internal */ + export function formatNode(node: Node, sourceFileLike: SourceFileLike, languageVariant: LanguageVariant, initialIndentation: number, delta: number, rulesProvider: RulesProvider): TextChange[] { + const range = { pos: 0, end: sourceFileLike.text.length }; + return formatSpanWorker( + range, + node, + initialIndentation, + delta, + getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), + rulesProvider.getFormatOptions(), + rulesProvider, + FormattingRequestKind.FormatSelection, + _ => false, // assume that node does not have any errors + sourceFileLike); + } + function formatSpan(originalRange: TextRange, sourceFile: SourceFile, options: FormatCodeSettings, rulesProvider: RulesProvider, requestKind: FormattingRequestKind): TextChange[] { + // find the smallest node that fully wraps the range and compute the initial indentation for the node + const enclosingNode = findEnclosingNode(originalRange, sourceFile); + return formatSpanWorker( + originalRange, + enclosingNode, + SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), + getOwnOrInheritedDelta(enclosingNode, options, sourceFile), + getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), + options, + rulesProvider, + requestKind, + prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), + sourceFile); + } - const rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); + function formatSpanWorker(originalRange: TextRange, + enclosingNode: Node, + initialIndentation: number, + delta: number, + formattingScanner: FormattingScanner, + options: FormatCodeSettings, + rulesProvider: RulesProvider, + requestKind: FormattingRequestKind, + rangeContainsError: (r: TextRange) => boolean, + sourceFile: SourceFileLike): TextChange[] { // formatting context is used by rules provider const formattingContext = new FormattingContext(sourceFile, requestKind); - - // find the smallest node that fully wraps the range and compute the initial indentation for the node - const enclosingNode = findEnclosingNode(originalRange, sourceFile); - - const formattingScanner = getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - - const initialIndentation = SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); - let previousRangeHasError: boolean; let previousRange: TextRangeWithKind; let previousParent: Node; @@ -351,7 +382,6 @@ namespace ts.formatting { undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; } - const delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } diff --git a/src/services/formatting/formattingContext.ts b/src/services/formatting/formattingContext.ts index bd5ca352476..26b538dfc5e 100644 --- a/src/services/formatting/formattingContext.ts +++ b/src/services/formatting/formattingContext.ts @@ -15,7 +15,7 @@ namespace ts.formatting { private contextNodeBlockIsOnOneLine: boolean; private nextNodeBlockIsOnOneLine: boolean; - constructor(public sourceFile: SourceFile, public formattingRequestKind: FormattingRequestKind) { + constructor(public readonly sourceFile: SourceFileLike, public formattingRequestKind: FormattingRequestKind) { } public updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node) { diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 2020352f86b..20d190de2f3 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -30,11 +30,11 @@ namespace ts.formatting { RescanJsxText, } - export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner { + export function getFormattingScanner(text: string, languageVariant: LanguageVariant, startPos: number, endPos: number): FormattingScanner { Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = sourceFile.languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; + scanner = languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); + scanner.setText(text); scanner.setTextPos(startPos); let wasNewLine = true; @@ -276,8 +276,8 @@ namespace ts.formatting { function isOnToken(): boolean { Debug.assert(scanner !== undefined); - const current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - const startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + const current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + const startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== SyntaxKind.EndOfFileToken && !isTrivia(current); } diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index 14e08e4857a..660d5f34a0e 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -24,6 +24,10 @@ namespace ts.formatting { return this.rulesMap; } + public getFormatOptions(): Readonly { + return this.options; + } + public ensureUpToDate(options: ts.FormatCodeSettings) { if (!this.options || !ts.compareDataObjects(this.options, options)) { const activeRules = this.createActiveRules(options); diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index eb9e1ba04c5..b5c901482a7 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -8,7 +8,19 @@ namespace ts.formatting { Unknown = -1 } - export function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number { + /** + * Computed indentation for a given position in source file + * @param position - position in file + * @param sourceFile - target source file + * @param options - set of editor options that control indentation + * @param assumeNewLineBeforeCloseBrace - false when getIndentation is called on the text from the real source file. + * true - when we need to assume that position is on the newline. This is usefult for codefixes, i.e. + * function f() { + * |} + * when inserting some text after open brace we would like to get the value of indentation as if newline was already there. + * However by default indentation at position | will be 0 so 'assumeNewLineBeforeCloseBrace' allows to override this behavior, + */ + export function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings, assumeNewLineBeforeCloseBrace = false): number { if (position > sourceFile.text.length) { return getBaseIndentation(options); // past EOF } @@ -71,13 +83,14 @@ namespace ts.formatting { if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; + const nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); + if (nextTokenKind !== NextTokenKind.Unknown) { + // handle cases when codefix is about to be inserted before the close brace + indentationDelta = assumeNewLineBeforeCloseBrace && nextTokenKind === NextTokenKind.CloseBrace ? options.indentSize : 0; } else { indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; } - break; } @@ -218,15 +231,21 @@ namespace ts.formatting { return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } - function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): boolean { + const enum NextTokenKind { + Unknown, + OpenBrace, + CloseBrace + } + + function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): NextTokenKind { const nextToken = findNextToken(precedingToken, current); if (!nextToken) { - return false; + return NextTokenKind.Unknown; } if (nextToken.kind === SyntaxKind.OpenBraceToken) { // open braces are always indented at the parent level - return true; + return NextTokenKind.OpenBrace; } else if (nextToken.kind === SyntaxKind.CloseBraceToken) { // close braces are indented at the parent level if they are located on the same line with cursor @@ -239,17 +258,17 @@ namespace ts.formatting { // $} const nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; + return lineAtPosition === nextTokenStartLine ? NextTokenKind.CloseBrace : NextTokenKind.Unknown; } - return false; + return NextTokenKind.Unknown; } - function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter { + function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFileLike): LineAndCharacter { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } - export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean { + export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean { if (parent.kind === SyntaxKind.IfStatement && (parent).elseStatement === child) { const elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile); Debug.assert(elseKeyword !== undefined); @@ -261,15 +280,15 @@ namespace ts.formatting { return false; } - function getContainingList(node: Node, sourceFile: SourceFile): NodeArray { + function getListIfStartEndIsInListRange(list: NodeArray, start: number, end: number) { + return list && rangeContainsStartEnd(list, start, end) ? list : undefined; + } + + export function getContainingList(node: Node, sourceFile: SourceFile): NodeArray { if (node.parent) { switch (node.parent.kind) { case SyntaxKind.TypeReference: - if ((node.parent).typeArguments && - rangeContainsStartEnd((node.parent).typeArguments, node.getStart(sourceFile), node.getEnd())) { - return (node.parent).typeArguments; - } - break; + return getListIfStartEndIsInListRange((node.parent).typeArguments, node.getStart(sourceFile), node.getEnd()); case SyntaxKind.ObjectLiteralExpression: return (node.parent).properties; case SyntaxKind.ArrayLiteralExpression: @@ -280,30 +299,26 @@ namespace ts.formatting { case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: + case SyntaxKind.Constructor: + case SyntaxKind.ConstructorType: case SyntaxKind.ConstructSignature: { const start = node.getStart(sourceFile); - if ((node.parent).typeParameters && - rangeContainsStartEnd((node.parent).typeParameters, start, node.getEnd())) { - return (node.parent).typeParameters; - } - if (rangeContainsStartEnd((node.parent).parameters, start, node.getEnd())) { - return (node.parent).parameters; - } - break; + return getListIfStartEndIsInListRange((node.parent).typeParameters, start, node.getEnd()) || + getListIfStartEndIsInListRange((node.parent).parameters, start, node.getEnd()); } + case SyntaxKind.ClassDeclaration: + return getListIfStartEndIsInListRange((node.parent).typeParameters, node.getStart(sourceFile), node.getEnd()); case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: { const start = node.getStart(sourceFile); - if ((node.parent).typeArguments && - rangeContainsStartEnd((node.parent).typeArguments, start, node.getEnd())) { - return (node.parent).typeArguments; - } - if ((node.parent).arguments && - rangeContainsStartEnd((node.parent).arguments, start, node.getEnd())) { - return (node.parent).arguments; - } - break; + return getListIfStartEndIsInListRange((node.parent).typeArguments, start, node.getEnd()) || + getListIfStartEndIsInListRange((node.parent).arguments, start, node.getEnd()); } + case SyntaxKind.VariableDeclarationList: + return getListIfStartEndIsInListRange((node.parent).declarations, node.getStart(sourceFile), node.getEnd()); + case SyntaxKind.NamedImports: + case SyntaxKind.NamedExports: + return getListIfStartEndIsInListRange((node.parent).elements, node.getStart(sourceFile), node.getEnd()); } } return undefined; @@ -400,7 +415,7 @@ namespace ts.formatting { value of 'character' for '$' is 3 value of 'column' for '$' is 6 (assuming that tab size is 4) */ - export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings) { + export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings) { let character = 0; let column = 0; for (let pos = startPos; pos < endPos; pos++) { @@ -421,7 +436,7 @@ namespace ts.formatting { return { column, character }; } - export function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): number { + export function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings): number { return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; } diff --git a/src/services/services.ts b/src/services/services.ts index df5330ebaed..e370dccac32 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -24,6 +24,7 @@ /// /// /// +/// /// /// @@ -63,7 +64,7 @@ namespace ts { return getSourceFileOfNode(this); } - public getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number { + public getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number { return getTokenPosOfNode(this, sourceFile, includeJsDocComment); } @@ -129,7 +130,7 @@ namespace ts { return list; } - private createChildren(sourceFile?: SourceFile) { + private createChildren(sourceFile?: SourceFileLike) { let children: Node[]; if (this.kind >= SyntaxKind.FirstNode) { scanner.setText((sourceFile || this.getSourceFile()).text); @@ -182,7 +183,7 @@ namespace ts { return this._children[index]; } - public getChildren(sourceFile?: SourceFile): Node[] { + public getChildren(sourceFile?: SourceFileLike): Node[] { if (!this._children) this.createChildren(sourceFile); return this._children; } @@ -231,7 +232,7 @@ namespace ts { return getSourceFileOfNode(this); } - public getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number { + public getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number { return getTokenPosOfNode(this, sourceFile, includeJsDocComment); } @@ -1682,7 +1683,7 @@ namespace ts { return []; } - function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] { + function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[] { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const span = { start, length: end - start }; @@ -1700,7 +1701,8 @@ namespace ts { program: program, newLineCharacter: newLineChar, host: host, - cancellationToken: cancellationToken + cancellationToken: cancellationToken, + rulesProvider: getRuleProvider(formatOptions) }; const fixes = codefix.getFixes(context); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts new file mode 100644 index 00000000000..6f8a67a0535 --- /dev/null +++ b/src/services/textChanges.ts @@ -0,0 +1,666 @@ +/* @internal */ +namespace ts.textChanges { + + /** + * Currently for simplicity we store recovered positions on the node itself. + * It can be changed to side-table later if we decide that current design is too invasive. + */ + function getPos(n: TextRange) { + return (n)["__pos"]; + } + + function setPos(n: TextRange, pos: number) { + (n)["__pos"] = pos; + } + + function getEnd(n: TextRange) { + return (n)["__end"]; + } + + function setEnd(n: TextRange, end: number) { + (n)["__end"] = end; + } + + export interface ConfigurableStart { + useNonAdjustedStartPosition?: boolean; + } + export interface ConfigurableEnd { + useNonAdjustedEndPosition?: boolean; + } + + export enum Position { + FullStart, + Start + } + + function skipWhitespacesAndLineBreaks(text: string, start: number) { + return skipTrivia(text, start, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + } + + function hasCommentsBeforeLineBreak(text: string, start: number) { + let i = start; + while (i < text.length) { + const ch = text.charCodeAt(i); + if (isWhiteSpaceSingleLine(ch)) { + i++; + continue; + } + return ch === CharacterCodes.slash; + } + return false; + } + + /** + * Usually node.pos points to a position immediately after the previous token. + * If this position is used as a beginning of the span to remove - it might lead to removing the trailing trivia of the previous node, i.e: + * const x; // this is x + * ^ - pos for the next variable declaration will point here + * const y; // this is y + * ^ - end for previous variable declaration + * Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding + * variable declaration and trailing trivia for 'y' should include (whitespace, comment 'this is y', newline). + * By default when removing nodes we adjust start and end positions to respect specification of the trivia above. + * If pos\end should be interpreted literally 'useNonAdjustedStartPosition' or 'useNonAdjustedEndPosition' should be set to true + */ + export type ConfigurableStartEnd = ConfigurableStart & ConfigurableEnd; + + export interface InsertNodeOptions { + /** + * Text to be inserted before the new node + */ + prefix?: string; + /** + * Text to be inserted after the new node + */ + suffix?: string; + /** + * Text of inserted node will be formatted with this indentation, otherwise indentation will be inferred from the old node + */ + indentation?: number; + /** + * Text of inserted node will be formatted with this delta, otherwise delta will be inferred from the new node kind + */ + delta?: number; + } + + export type ChangeNodeOptions = ConfigurableStartEnd & InsertNodeOptions; + + interface Change { + readonly sourceFile: SourceFile; + readonly range: TextRange; + readonly useIndentationFromFile?: boolean; + readonly node?: Node; + readonly options?: ChangeNodeOptions; + } + + export function getSeparatorCharacter(separator: Token) { + return tokenToString(separator.kind); + } + + export function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStart, position: Position) { + if (options.useNonAdjustedStartPosition) { + return node.getFullStart(); + } + const fullStart = node.getFullStart(); + const start = node.getStart(sourceFile); + if (fullStart === start) { + return start; + } + const fullStartLine = getLineStartPositionForPosition(fullStart, sourceFile); + const startLine = getLineStartPositionForPosition(start, sourceFile); + if (startLine === fullStartLine) { + // full start and start of the node are on the same line + // a, b; + // ^ ^ + // | start + // fullstart + // when b is replaced - we usually want to keep the leading trvia + // when b is deleted - we delete it + return position === Position.Start ? start : fullStart; + } + // get start position of the line following the line that contains fullstart position + let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + // skip whitespaces/newlines + adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); + return getStartPositionOfLine(getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); + } + + export function getAdjustedEndPosition(sourceFile: SourceFile, node: Node, options: ConfigurableEnd) { + if (options.useNonAdjustedEndPosition) { + return node.getEnd(); + } + const end = node.getEnd(); + const newEnd = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); + // check if last character before newPos is linebreak + // if yes - considered all skipped trivia to be trailing trivia of the node + return newEnd !== end && isLineBreak(sourceFile.text.charCodeAt(newEnd - 1)) + ? newEnd + : end; + } + + /** + * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element + */ + function isSeparator(node: Node, candidate: Node): candidate is Token { + return candidate && node.parent && (candidate.kind === SyntaxKind.CommaToken || (candidate.kind === SyntaxKind.SemicolonToken && node.parent.kind === SyntaxKind.ObjectLiteralExpression)); + } + + function spaces(count: number) { + let s = ""; + for (let i = 0; i < count; i++) { + s += " "; + } + return s; + } + + export class ChangeTracker { + private changes: Change[] = []; + private readonly newLineCharacter: string; + + public static fromCodeFixContext(context: CodeFixContext) { + return new ChangeTracker(context.newLineCharacter === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed, context.rulesProvider); + } + + constructor( + private readonly newLine: NewLineKind, + private readonly rulesProvider: formatting.RulesProvider, + private readonly validator?: (text: NonFormattedText) => void) { + this.newLineCharacter = getNewLineCharacter({ newLine }); + } + + public deleteNode(sourceFile: SourceFile, node: Node, options: ConfigurableStartEnd = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + const endPosition = getAdjustedEndPosition(sourceFile, node, options); + this.changes.push({ sourceFile, options, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public deleteRange(sourceFile: SourceFile, range: TextRange) { + this.changes.push({ sourceFile, range }); + return this; + } + + public deleteNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, options: ConfigurableStartEnd = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + const endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile, options, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public deleteNodeInList(sourceFile: SourceFile, node: Node) { + const containingList = formatting.SmartIndenter.getContainingList(node, sourceFile); + if (!containingList) { + Debug.fail("node is not a list element"); + return this; + } + const index = containingList.indexOf(node); + if (index < 0) { + return this; + } + if (containingList.length === 1) { + this.deleteNode(sourceFile, node); + return this; + } + if (index !== containingList.length - 1) { + const nextToken = getTokenAtPosition(sourceFile, node.end); + if (nextToken && isSeparator(node, nextToken)) { + // find first non-whitespace position in the leading trivia of the node + const startPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + const nextElement = containingList[index + 1]; + /// find first non-whitespace position in the leading trivia of the next node + const endPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + } + else { + const previousToken = getTokenAtPosition(sourceFile, containingList[index - 1].end); + if (previousToken && isSeparator(node, previousToken)) { + this.deleteNodeRange(sourceFile, previousToken, node); + } + } + return this; + } + + public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: InsertNodeOptions = {}) { + this.changes.push({ sourceFile, range, options, node: newNode }); + return this; + } + + public replaceNode(sourceFile: SourceFile, oldNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + const endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public replaceNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + const endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) { + this.changes.push({ sourceFile, options, node: newNode, range: { pos: pos, end: pos } }); + return this; + } + + public insertNodeBefore(sourceFile: SourceFile, before: Node, newNode: Node, options: InsertNodeOptions & ConfigurableStart = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); + return this; + } + + public insertNodeAfter(sourceFile: SourceFile, after: Node, newNode: Node, options: InsertNodeOptions & ConfigurableEnd = {}) { + if ((isStatementButNotDeclaration(after)) || + after.kind === SyntaxKind.PropertyDeclaration || + after.kind === SyntaxKind.PropertySignature || + after.kind === SyntaxKind.MethodSignature) { + // check if previous statement ends with semicolon + // if not - insert semicolon to preserve the code from changing the meaning due to ASI + if (sourceFile.text.charCodeAt(after.end - 1) !== CharacterCodes.semicolon) { + this.changes.push({ + sourceFile, + options: {}, + range: { pos: after.end, end: after.end }, + node: createToken(SyntaxKind.SemicolonToken) + }) + } + } + const endPosition = getAdjustedEndPosition(sourceFile, after, options); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); + return this; + } + + /** + * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, + * i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that + * for them separators are treated as the part of the node. + */ + public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { + const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile); + if (!containingList) { + Debug.fail("node is not a list element"); + return this; + } + const index = containingList.indexOf(after); + if (index < 0) { + return this; + } + const end = after.getEnd(); + if (index !== containingList.length - 1) { + // any element except the last one + // use next sibling as an anchor + const nextToken = getTokenAtPosition(sourceFile, after.end); + if (nextToken && isSeparator(after, nextToken)) { + // for list + // a, b, c + // create change for adding 'e' after 'a' as + // - find start of next element after a (it is b) + // - use this start as start and end position in final change + // - build text of change by formatting the text of node + separator + whitespace trivia of b + + // in multiline case it will work as + // a, + // b, + // c, + // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') + // a,* + //***insertedtext# + //###b, + // c, + // find line and character of the next element + const lineAndCharOfNextElement = getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); + // find line and character of the token that precedes next element (usually it is separator) + const lineAndCharOfNextToken = getLineAndCharacterOfPosition(sourceFile, nextToken.end); + let prefix: string; + let startPos: number; + if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { + // next element is located on the same line with separator: + // a,$$$$b + // ^ ^ + // | |-next element + // |-separator + // where $$$ is some leading trivia + // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces + // a, x,$$$$b + // ^ ^ ^ + // | | |-next element + // | |-new inserted node padded with spaces + // |-separator + startPos = nextToken.end; + prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); + } + else { + // next element is located on different line that separator + // let insert position be the beginning of the line that contains next element + startPos = getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); + } + + this.changes.push({ + sourceFile, + range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, + node: newNode, + useIndentationFromFile: true, + options: { + prefix, + // write separator and leading trivia of the next element as suffix + suffix: `${tokenToString(nextToken.kind)}${sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile))}` + } + }); + } + } + else { + const afterStart = after.getStart(sourceFile); + const afterStartLinePosition = getLineStartPositionForPosition(afterStart, sourceFile); + + let separator: SyntaxKind.CommaToken | SyntaxKind.SemicolonToken; + let multilineList = false; + + // insert element after the last element in the list that has more than one item + // pick the element preceding the after element to: + // - pick the separator + // - determine if list is a multiline + if (containingList.length === 1) { + // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise + // i.e. var x = 1 // this is x + // | new element will be inserted at this position + separator = SyntaxKind.CommaToken; + } + else { + // element has more than one element, pick separator from the list + const tokenBeforeInsertPosition = findPrecedingToken(after.pos, sourceFile); + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : SyntaxKind.CommaToken; + // determine if list is multiline by checking lines of after element and element that precedes it. + const afterMinusOneStartLinePosition = getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); + multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; + } + if (hasCommentsBeforeLineBreak(sourceFile.text, after.end)) { + // in this case we'll always treat containing list as multiline + multilineList = true; + } + if (multilineList) { + // insert separator immediately following the 'after' node to preserve comments in trailing trivia + this.changes.push({ + sourceFile, + range: { pos: end, end }, + node: createToken(separator), + options: {} + }); + // use the same indentation as 'after' item + const indentation = formatting.SmartIndenter.findFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, this.rulesProvider.getFormatOptions()); + // insert element before the line break on the line that contains 'after' element + let insertPos = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false); + if (insertPos !== end && isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { + insertPos-- + } + this.changes.push({ + sourceFile, + range: { pos: insertPos, end: insertPos }, + node: newNode, + options: { indentation, prefix: this.newLineCharacter } + }); + } + else { + this.changes.push({ + sourceFile, + range: { pos: end, end }, + node: newNode, + options: { prefix: `${tokenToString(separator)} ` } + }); + } + } + return this; + } + + public getChanges(): FileTextChanges[] { + const changesPerFile = createFileMap(); + // group changes per file + for (const c of this.changes) { + let changesInFile = changesPerFile.get(c.sourceFile.path); + if (!changesInFile) { + changesPerFile.set(c.sourceFile.path, changesInFile = []); + }; + changesInFile.push(c); + } + // convert changes + const fileChangesList: FileTextChanges[] = []; + changesPerFile.forEachValue(path => { + const changesInFile = changesPerFile.get(path); + const sourceFile = changesInFile[0].sourceFile; + const fileTextChanges: FileTextChanges = { fileName: sourceFile.fileName, textChanges: [] }; + for (const c of ChangeTracker.normalize(changesInFile)) { + fileTextChanges.textChanges.push({ + span: this.computeSpan(c, sourceFile), + newText: this.computeNewText(c, sourceFile) + }); + } + fileChangesList.push(fileTextChanges); + }); + + return fileChangesList; + } + + private computeSpan(change: Change, _sourceFile: SourceFile): TextSpan { + return createTextSpanFromBounds(change.range.pos, change.range.end); + } + + private computeNewText(change: Change, sourceFile: SourceFile): string { + if (!change.node) { + // deletion case + return ""; + } + const options = change.options || {}; + const nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonFormattedText); + } + + const formatOptions = this.rulesProvider.getFormatOptions(); + const pos = change.range.pos; + const posStartsLine = getLineStartPositionForPosition(pos, sourceFile) === pos; + + const initialIndentation = + change.options.indentation !== undefined + ? change.options.indentation + : change.useIndentationFromFile + ? formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix == this.newLineCharacter)) + : 0; + const delta = + change.options.delta !== undefined + ? change.options.delta + : formatting.SmartIndenter.shouldIndentChildNode(change.node) + ? formatOptions.indentSize + : 0; + + let text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line + // however keep indentation if it is was forced + text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + return (options.prefix || "") + text + (options.suffix || ""); + } + + private static normalize(changes: Change[]) { + // order changes by start position + const normalized = stableSort(changes, (a, b) => a.range.pos - b.range.pos); + // verify that end position of the change is less than start position of the next change + for (let i = 0; i < normalized.length - 2; i++) { + Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); + } + return normalized; + } + } + + export interface NonFormattedText { + readonly text: string; + readonly node: Node; + } + + export function getNonformattedText(node: Node, sourceFile: SourceFile, newLine: NewLineKind): NonFormattedText { + const options = { newLine, target: sourceFile.languageVersion }; + const writer = new Writer(getNewLineCharacter(options)); + const printer = createPrinter(options, writer); + printer.writeNode(EmitHint.Unspecified, node, sourceFile, writer); + return { text: writer.getText(), node: assignPositionsToNode(node) }; + } + + export function applyFormatting(nonFormattedText: NonFormattedText, sourceFile: SourceFile, initialIndentation: number, delta: number, rulesProvider: formatting.RulesProvider) { + const lineMap = computeLineStarts(nonFormattedText.text); + const file: SourceFileLike = { + text: nonFormattedText.text, + lineMap, + getLineAndCharacterOfPosition: pos => computeLineAndCharacterOfPosition(lineMap, pos) + }; + const changes = formatting.formatNode(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); + return applyChanges(nonFormattedText.text, changes); + } + + export function applyChanges(text: string, changes: TextChange[]): string { + for (let i = changes.length - 1; i >= 0; i--) { + const change = changes[i]; + text = `${text.substring(0, change.span.start)}${change.newText}${text.substring(textSpanEnd(change.span))}`; + } + return text; + } + + function isTrivia(s: string) { + return skipTrivia(s, 0) === s.length; + } + + const nullTransformationContext: TransformationContext = { + enableEmitNotification: noop, + enableSubstitution: noop, + endLexicalEnvironment: () => undefined, + getCompilerOptions: notImplemented, + getEmitHost: notImplemented, + getEmitResolver: notImplemented, + hoistFunctionDeclaration: noop, + hoistVariableDeclaration: noop, + isEmitNotificationEnabled: notImplemented, + isSubstitutionEnabled: notImplemented, + onEmitNode: noop, + onSubstituteNode: notImplemented, + readEmitHelpers: notImplemented, + requestEmitHelper: noop, + resumeLexicalEnvironment: noop, + startLexicalEnvironment: noop, + suspendLexicalEnvironment: noop + }; + + function assignPositionsToNode(node: Node): Node { + const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray); + // create proxy node for non synthesized nodes + const newNode = nodeIsSynthesized(visited) + ? visited + : (Proxy.prototype = visited, new (Proxy)()); + newNode.pos = getPos(node); + newNode.end = getEnd(node); + return newNode; + + function Proxy() { } + } + + function assignPositionsToNodeArray(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) { + const visited = visitNodes(nodes, visitor, test, start, count); + if (!visited) { + return visited; + } + // clone nodearray if necessary + const nodeArray = visited === nodes ? createNodeArray(visited.slice(0)) : visited; + nodeArray.pos = getPos(nodes); + nodeArray.end = getEnd(nodes); + return nodeArray; + } + + class Writer implements EmitTextWriter, PrintHandlers { + private lastNonTriviaPosition = 0; + private readonly writer: EmitTextWriter; + + public readonly onEmitNode: PrintHandlers["onEmitNode"]; + public readonly onBeforeEmitNodeArray: PrintHandlers["onBeforeEmitNodeArray"]; + public readonly onAfterEmitNodeArray: PrintHandlers["onAfterEmitNodeArray"]; + + constructor(newLine: string) { + this.writer = createTextWriter(newLine); + this.onEmitNode = (hint, node, printCallback) => { + if (node) { + setPos(node, this.lastNonTriviaPosition); + } + printCallback(hint, node); + if (node) { + setEnd(node, this.lastNonTriviaPosition); + } + }; + this.onBeforeEmitNodeArray = nodes => { + if (nodes) { + setPos(nodes, this.lastNonTriviaPosition); + } + }; + this.onAfterEmitNodeArray = nodes => { + if (nodes) { + setEnd(nodes, this.lastNonTriviaPosition); + } + }; + } + + private setLastNonTriviaPosition(s: string, force: boolean) { + if (force || !isTrivia(s)) { + this.lastNonTriviaPosition = this.writer.getTextPos(); + let i = 0; + while (isWhiteSpace(s.charCodeAt(s.length - i - 1))) { + i++; + } + // trim trailing whitespaces + this.lastNonTriviaPosition -= i; + } + } + + write(s: string): void { + this.writer.write(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + } + writeTextOfNode(text: string, node: Node): void { + this.writer.writeTextOfNode(text, node); + } + writeLine(): void { + this.writer.writeLine(); + } + increaseIndent(): void { + this.writer.increaseIndent(); + } + decreaseIndent(): void { + this.writer.decreaseIndent(); + } + getText(): string { + return this.writer.getText(); + } + rawWrite(s: string): void { + this.writer.rawWrite(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + } + writeLiteral(s: string): void { + this.writer.writeLiteral(s); + this.setLastNonTriviaPosition(s, /*force*/ true); + } + getTextPos(): number { + return this.writer.getTextPos(); + } + getLine(): number { + return this.writer.getLine(); + } + getColumn(): number { + return this.writer.getColumn(); + } + getIndent(): number { + return this.writer.getIndent(); + } + isAtStartOfLine(): boolean { + return this.writer.isAtStartOfLine(); + } + reset(): void { + this.writer.reset(); + this.lastNonTriviaPosition = 0; + } + } +} \ No newline at end of file diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 93f861e80aa..b1391bd7300 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -63,6 +63,7 @@ "shims.ts", "signatureHelp.ts", "symbolDisplay.ts", + "textChanges.ts", "formatting/formatting.ts", "formatting/formattingContext.ts", "formatting/formattingRequestKind.ts", diff --git a/src/services/types.ts b/src/services/types.ts index c7852db6d6e..149bb4340dc 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -4,7 +4,11 @@ namespace ts { getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; + /* @internal */ + getChildren(sourceFile?: SourceFileLike): Node[]; getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; + /* @internal */ + getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; getWidth(sourceFile?: SourceFile): number; @@ -59,6 +63,10 @@ namespace ts { update(newText: string, textChangeRange: TextChangeRange): SourceFile; } + export interface SourceFileLike { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + } + /** * Represents an immutable snapshot of a script at a specified time.Once acquired, the * snapshot is observably immutable. i.e. the same calls with the same parameters will return @@ -248,7 +256,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 7c5bf862fc8..1b32b3bbad7 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -394,8 +394,8 @@ namespace ts { list: Node; } - export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number { - const lineStarts = sourceFile.getLineStarts(); + export function getLineStartPositionForPosition(position: number, sourceFile: SourceFileLike): number { + const lineStarts = getLineStarts(sourceFile); const line = sourceFile.getLineAndCharacterOfPosition(position).line; return lineStarts[line]; } @@ -604,7 +604,7 @@ namespace ts { return !!findChildOfKind(n, kind, sourceFile); } - export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node | undefined { + export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFileLike): Node | undefined { return forEach(n.getChildren(sourceFile), c => c.kind === kind && c); } @@ -1003,10 +1003,6 @@ namespace ts { return undefined; } - export function isToken(n: Node): boolean { - return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; - } - export function isWord(kind: SyntaxKind): boolean { return kind === SyntaxKind.Identifier || isKeyword(kind); } @@ -1384,8 +1380,8 @@ namespace ts { }; } - export function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { + export function getOpenBrace(constructor: ConstructorDeclaration, sourceFile: SourceFile) { // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); + return constructor.body.getFirstToken(sourceFile); } } diff --git a/tests/baselines/reference/textChanges/deleteNode1.js b/tests/baselines/reference/textChanges/deleteNode1.js new file mode 100644 index 00000000000..c73c0eaf9f9 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode1.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1; // some comment - 1 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode2.js b/tests/baselines/reference/textChanges/deleteNode2.js new file mode 100644 index 00000000000..828a9b5b8fa --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1;var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode3.js b/tests/baselines/reference/textChanges/deleteNode3.js new file mode 100644 index 00000000000..acb26c7daa7 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode3.js @@ -0,0 +1,14 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1; // some comment - 1 + // comment 3 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode4.js b/tests/baselines/reference/textChanges/deleteNode4.js new file mode 100644 index 00000000000..b6edb25bc5c --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode4.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1; // comment 3 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode5.js b/tests/baselines/reference/textChanges/deleteNode5.js new file mode 100644 index 00000000000..6f896535f0f --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode5.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js b/tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js new file mode 100644 index 00000000000..d8d54153eaa --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x; + y = 1; +} + +===MODIFIED=== + +class A { + y = 1; +} diff --git a/tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js b/tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js new file mode 100644 index 00000000000..8d18d820214 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x + y = 1; +} + +===MODIFIED=== + +class A { + y = 1; +} diff --git a/tests/baselines/reference/textChanges/deleteNodeInList1.js b/tests/baselines/reference/textChanges/deleteNodeInList1.js new file mode 100644 index 00000000000..b603913566d --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1, b = 2, c = 3; +===MODIFIED=== +var b = 2, c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList10.js b/tests/baselines/reference/textChanges/deleteNodeInList10.js new file mode 100644 index 00000000000..46da605a71a --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList10.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number,b: string,c = true) { + return 1; +} +===MODIFIED=== + +function foo(b: string,c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList11.js b/tests/baselines/reference/textChanges/deleteNodeInList11.js new file mode 100644 index 00000000000..f5aa666e527 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList11.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number,b: string,c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number,c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList12.js b/tests/baselines/reference/textChanges/deleteNodeInList12.js new file mode 100644 index 00000000000..db05ef06db9 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList12.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number,b: string,c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number,b: string) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList13.js b/tests/baselines/reference/textChanges/deleteNodeInList13.js new file mode 100644 index 00000000000..599d3a31d43 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList13.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo( + a: number, + b: string, + c = true) { + return 1; +} +===MODIFIED=== + +function foo( + b: string, + c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList14.js b/tests/baselines/reference/textChanges/deleteNodeInList14.js new file mode 100644 index 00000000000..da3596b38b2 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList14.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo( + a: number, + b: string, + c = true) { + return 1; +} +===MODIFIED=== + +function foo( + a: number, + c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList15.js b/tests/baselines/reference/textChanges/deleteNodeInList15.js new file mode 100644 index 00000000000..02f649dabd2 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList15.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo( + a: number, + b: string, + c = true) { + return 1; +} +===MODIFIED=== + +function foo( + a: number, + b: string) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList1_1.js b/tests/baselines/reference/textChanges/deleteNodeInList1_1.js new file mode 100644 index 00000000000..87709601c42 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList1_1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1,b = 2,c = 3; +===MODIFIED=== +var b = 2,c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList2.js b/tests/baselines/reference/textChanges/deleteNodeInList2.js new file mode 100644 index 00000000000..18e4a0cd304 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList2.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1, b = 2, c = 3; +===MODIFIED=== +var a = 1, c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList2_1.js b/tests/baselines/reference/textChanges/deleteNodeInList2_1.js new file mode 100644 index 00000000000..b4098a89302 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList2_1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1,b = 2,c = 3; +===MODIFIED=== +var a = 1,c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList3.js b/tests/baselines/reference/textChanges/deleteNodeInList3.js new file mode 100644 index 00000000000..1c6ff4aa294 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList3.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1, b = 2, c = 3; +===MODIFIED=== +var a = 1, b = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList3_1.js b/tests/baselines/reference/textChanges/deleteNodeInList3_1.js new file mode 100644 index 00000000000..ead2a1a42f8 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList3_1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1,b = 2,c = 3; +===MODIFIED=== +var a = 1,b = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList4.js b/tests/baselines/reference/textChanges/deleteNodeInList4.js new file mode 100644 index 00000000000..61bdf9159cb --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList4.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace M { + var a = 1, + b = 2, + c = 3; +} +===MODIFIED=== + +namespace M { + var b = 2, + c = 3; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList4_1.js b/tests/baselines/reference/textChanges/deleteNodeInList4_1.js new file mode 100644 index 00000000000..19ff5475d1a --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList4_1.js @@ -0,0 +1,17 @@ +===ORIGINAL=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} +===MODIFIED=== + +namespace M { + var // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList5.js b/tests/baselines/reference/textChanges/deleteNodeInList5.js new file mode 100644 index 00000000000..0ed65877d27 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList5.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace M { + var a = 1, + b = 2, + c = 3; +} +===MODIFIED=== + +namespace M { + var a = 1, + c = 3; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList5_1.js b/tests/baselines/reference/textChanges/deleteNodeInList5_1.js new file mode 100644 index 00000000000..224b92481d3 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList5_1.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} +===MODIFIED=== + +namespace M { + var a = 1, // comment 1 + // comment 4 + c = 3; // comment 5 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList6.js b/tests/baselines/reference/textChanges/deleteNodeInList6.js new file mode 100644 index 00000000000..4093329023f --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList6.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace M { + var a = 1, + b = 2, + c = 3; +} +===MODIFIED=== + +namespace M { + var a = 1, + b = 2; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList6_1.js b/tests/baselines/reference/textChanges/deleteNodeInList6_1.js new file mode 100644 index 00000000000..6acc20aa826 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList6_1.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} +===MODIFIED=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2; // comment 5 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList7.js b/tests/baselines/reference/textChanges/deleteNodeInList7.js new file mode 100644 index 00000000000..564ff3f86aa --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList7.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number, b: string, c = true) { + return 1; +} +===MODIFIED=== + +function foo(b: string, c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList8.js b/tests/baselines/reference/textChanges/deleteNodeInList8.js new file mode 100644 index 00000000000..b3a0a0f4c47 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList8.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number, b: string, c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number, c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList9.js b/tests/baselines/reference/textChanges/deleteNodeInList9.js new file mode 100644 index 00000000000..96878a6086d --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList9.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number, b: string, c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number, b: string) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeRange1.js b/tests/baselines/reference/textChanges/deleteNodeRange1.js new file mode 100644 index 00000000000..f9fa45ebb1a --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange1.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteNodeRange2.js b/tests/baselines/reference/textChanges/deleteNodeRange2.js new file mode 100644 index 00000000000..aacea6ff5ee --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange2.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1;// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteNodeRange3.js b/tests/baselines/reference/textChanges/deleteNodeRange3.js new file mode 100644 index 00000000000..bb2bb36ca2c --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange3.js @@ -0,0 +1,17 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 + // comment 5 +// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteNodeRange4.js b/tests/baselines/reference/textChanges/deleteNodeRange4.js new file mode 100644 index 00000000000..3e9ad960b13 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange4.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1; // comment 5 +// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteRange1.js b/tests/baselines/reference/textChanges/deleteRange1.js new file mode 100644 index 00000000000..362e678452e --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteRange1.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo() { + return 1; +} + +function bar() { + return 2; +} + +===MODIFIED=== + +function bar() { + return 2; +} diff --git a/tests/baselines/reference/textChanges/extractMethodLike.js b/tests/baselines/reference/textChanges/extractMethodLike.js new file mode 100644 index 00000000000..fa1d625dc4d --- /dev/null +++ b/tests/baselines/reference/textChanges/extractMethodLike.js @@ -0,0 +1,49 @@ +===ORIGINAL=== + +namespace M +{ + namespace M2 + { + function foo() { + // comment 1 + const x = 1; + + /** + * comment 2 line 1 + * comment 2 line 2 + */ + function f() { + return 100; + } + const y = 2; // comment 3 + return 1; + } + } +} +===MODIFIED=== + +namespace M +{ + function bar(): any + { + /** + * comment 2 line 1 + * comment 2 line 2 + */ + function f() + { + return 100; + } + const y = 2; // comment 3 + return 1; + } + namespace M2 + { + function foo() { + // comment 1 + const x = 1; + + return bar(); + } + } +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAfter1.js b/tests/baselines/reference/textChanges/insertNodeAfter1.js new file mode 100644 index 00000000000..e6d7387f6bc --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter1.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + public class class1 implements interface1 + { + property1: boolean; + } + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAfter2.js b/tests/baselines/reference/textChanges/insertNodeAfter2.js new file mode 100644 index 00000000000..7c027e35b50 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter2.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +public class class1 implements interface1 +{ + property1: boolean; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js b/tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js new file mode 100644 index 00000000000..41bfb72b574 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +class A { + constructor() { + + } +} + +===MODIFIED=== + +class A { + constructor() { + super(); + + } +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfter3.js b/tests/baselines/reference/textChanges/insertNodeAfter3.js new file mode 100644 index 00000000000..3765bbaf032 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter3.js @@ -0,0 +1,14 @@ +===ORIGINAL=== + +class A { + constructor() { + } +} + +===MODIFIED=== + +class A { + constructor() { + super(); + } +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfter4.js b/tests/baselines/reference/textChanges/insertNodeAfter4.js new file mode 100644 index 00000000000..3ca51db4989 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter4.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +class A { + constructor() { + var x = 1; + } +} + +===MODIFIED=== + +class A { + constructor() { + var x = 1; + super(); + } +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfterInClass1.js b/tests/baselines/reference/textChanges/insertNodeAfterInClass1.js new file mode 100644 index 00000000000..841d43fef97 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfterInClass1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x +} + +===MODIFIED=== + +class A { + x; + a: boolean; +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfterInClass2.js b/tests/baselines/reference/textChanges/insertNodeAfterInClass2.js new file mode 100644 index 00000000000..1d583d8ac90 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfterInClass2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x; +} + +===MODIFIED=== + +class A { + x; + a: boolean; +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js b/tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js new file mode 100644 index 00000000000..1c3bbe4d3e2 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js @@ -0,0 +1,21 @@ +===ORIGINAL=== + +class A { + x; +} +===MODIFIED=== + +class A { + x; + 0; + 1; + 2; + 3; + 4; + 5; + 6; + 7; + 8; + 9; + 10; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAt1.js b/tests/baselines/reference/textChanges/insertNodeAt1.js new file mode 100644 index 00000000000..9c7ac46f8a8 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAt1.js @@ -0,0 +1,22 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +public class class1 implements interface1 +{ + property1: boolean; +} +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAt2.js b/tests/baselines/reference/textChanges/insertNodeAt2.js new file mode 100644 index 00000000000..81c3e2afc35 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAt2.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var yz1 = { + p1: 1 +}; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeBefore1.js b/tests/baselines/reference/textChanges/insertNodeBefore1.js new file mode 100644 index 00000000000..deebe10b694 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeBefore1.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + public class class1 implements interface1 + { + property1: boolean; + } + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeBefore2.js b/tests/baselines/reference/textChanges/insertNodeBefore2.js new file mode 100644 index 00000000000..1792cd5e69c --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeBefore2.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +public class class1 implements interface1 +{ + property1: boolean; +} +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator1.js b/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator1.js new file mode 100644 index 00000000000..0c47c26221f --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x = foo +} + +===MODIFIED=== + +class A { + x = foo; + [1]: any; +} diff --git a/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator2.js b/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator2.js new file mode 100644 index 00000000000..bd6302b29a6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator2.js @@ -0,0 +1,14 @@ +===ORIGINAL=== + +class A { + x() { + } +} + +===MODIFIED=== + +class A { + x() { + } + [1]: any; +} diff --git a/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator1.js b/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator1.js new file mode 100644 index 00000000000..61910e64dd5 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +interface A { + x +} + +===MODIFIED=== + +interface A { + x; + [1]: any; +} diff --git a/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator2.js b/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator2.js new file mode 100644 index 00000000000..6e88a371eb6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +interface A { + x() +} + +===MODIFIED=== + +interface A { + x(); + [1]: any; +} diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter1.js b/tests/baselines/reference/textChanges/insertNodeInListAfter1.js new file mode 100644 index 00000000000..9b0ed7b819d --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter1.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const x = 1, y = 2; +===MODIFIED=== + +const x = 1, z = 1, y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter10.js b/tests/baselines/reference/textChanges/insertNodeInListAfter10.js new file mode 100644 index 00000000000..300230bf51c --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter10.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +import { + x +} from "bar" +===MODIFIED=== + +import { + x, b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter11.js b/tests/baselines/reference/textChanges/insertNodeInListAfter11.js new file mode 100644 index 00000000000..f0ba43a0f3a --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter11.js @@ -0,0 +1,11 @@ +===ORIGINAL=== + +import { + x // this is x +} from "bar" +===MODIFIED=== + +import { + x, // this is x + b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter12.js b/tests/baselines/reference/textChanges/insertNodeInListAfter12.js new file mode 100644 index 00000000000..79e7bb2c8b6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter12.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +import { + x +} from "bar" +===MODIFIED=== + +import { + x, a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter13.js b/tests/baselines/reference/textChanges/insertNodeInListAfter13.js new file mode 100644 index 00000000000..a7ac7179ab6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter13.js @@ -0,0 +1,11 @@ +===ORIGINAL=== + +import { + x // this is x +} from "bar" +===MODIFIED=== + +import { + x, // this is x + a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter14.js b/tests/baselines/reference/textChanges/insertNodeInListAfter14.js new file mode 100644 index 00000000000..e44a21723be --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter14.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x +} from "bar" +===MODIFIED=== + +import { + x0, + x, + b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter15.js b/tests/baselines/reference/textChanges/insertNodeInListAfter15.js new file mode 100644 index 00000000000..a80bdc2db5e --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter15.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x // this is x +} from "bar" +===MODIFIED=== + +import { + x0, + x, // this is x + b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter16.js b/tests/baselines/reference/textChanges/insertNodeInListAfter16.js new file mode 100644 index 00000000000..07f8db919f8 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter16.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x +} from "bar" +===MODIFIED=== + +import { + x0, + x, + a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter17.js b/tests/baselines/reference/textChanges/insertNodeInListAfter17.js new file mode 100644 index 00000000000..990139408ee --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter17.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x // this is x +} from "bar" +===MODIFIED=== + +import { + x0, + x, // this is x + a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter18.js b/tests/baselines/reference/textChanges/insertNodeInListAfter18.js new file mode 100644 index 00000000000..b25a3f46346 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter18.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +import { + x0, x +} from "bar" +===MODIFIED=== + +import { + x0, x, a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter2.js b/tests/baselines/reference/textChanges/insertNodeInListAfter2.js new file mode 100644 index 00000000000..32e8e63c0f6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter2.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const x = 1, y = 2; +===MODIFIED=== + +const x = 1, y = 2, z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter3.js b/tests/baselines/reference/textChanges/insertNodeInListAfter3.js new file mode 100644 index 00000000000..70a0b0bddcb --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter3.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const /*x*/ x = 1, /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, z = 1, /*y*/ y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter4.js b/tests/baselines/reference/textChanges/insertNodeInListAfter4.js new file mode 100644 index 00000000000..4a30acd7071 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter4.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const /*x*/ x = 1, /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, /*y*/ y = 2, z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter5.js b/tests/baselines/reference/textChanges/insertNodeInListAfter5.js new file mode 100644 index 00000000000..42d5fe2ca40 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter5.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const x = 1; +===MODIFIED=== + +const x = 1, z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter6.js b/tests/baselines/reference/textChanges/insertNodeInListAfter6.js new file mode 100644 index 00000000000..06eae7372a9 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter6.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const x = 1, + y = 2; +===MODIFIED=== + +const x = 1, + z = 1, + y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter7.js b/tests/baselines/reference/textChanges/insertNodeInListAfter7.js new file mode 100644 index 00000000000..bef01503683 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter7.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const x = 1, + y = 2; +===MODIFIED=== + +const x = 1, + y = 2, + z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter8.js b/tests/baselines/reference/textChanges/insertNodeInListAfter8.js new file mode 100644 index 00000000000..e3c44b14274 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter8.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const /*x*/ x = 1, + /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, + z = 1, + /*y*/ y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter9.js b/tests/baselines/reference/textChanges/insertNodeInListAfter9.js new file mode 100644 index 00000000000..510984b7574 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter9.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const /*x*/ x = 1, + /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, + /*y*/ y = 2, + z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInStatementListAfterNodeWithoutSeparator1.js b/tests/baselines/reference/textChanges/insertNodeInStatementListAfterNodeWithoutSeparator1.js new file mode 100644 index 00000000000..b28b1579dfc --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInStatementListAfterNodeWithoutSeparator1.js @@ -0,0 +1,8 @@ +===ORIGINAL=== + +let x = foo + +===MODIFIED=== + +let x = foo; +(1); diff --git a/tests/baselines/reference/textChanges/replaceNode1.js b/tests/baselines/reference/textChanges/replaceNode1.js new file mode 100644 index 00000000000..8511d510385 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode1.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js b/tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js new file mode 100644 index 00000000000..44183d402ab --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace A { + const x = 1, y = "2"; +} + +===MODIFIED=== + +namespace A { + const x = 1, z1 = { + p1: 1 + }; +} diff --git a/tests/baselines/reference/textChanges/replaceNode2.js b/tests/baselines/reference/textChanges/replaceNode2.js new file mode 100644 index 00000000000..66a17f7c910 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode2.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; +public class class1 implements interface1 +{ + property1: boolean; +} +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode3.js b/tests/baselines/reference/textChanges/replaceNode3.js new file mode 100644 index 00000000000..9f321a97431 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode3.js @@ -0,0 +1,21 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} + // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode4.js b/tests/baselines/reference/textChanges/replaceNode4.js new file mode 100644 index 00000000000..e5bbf0e306d --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode4.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1;public class class1 implements interface1 +{ + property1: boolean; +} // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode5.js b/tests/baselines/reference/textChanges/replaceNode5.js new file mode 100644 index 00000000000..ad3ec0ab0ea --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode5.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== +public class class1 implements interface1 +{ + property1: boolean; +} // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange1.js b/tests/baselines/reference/textChanges/replaceNodeRange1.js new file mode 100644 index 00000000000..5fc16960a8a --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange1.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange2.js b/tests/baselines/reference/textChanges/replaceNodeRange2.js new file mode 100644 index 00000000000..e8f9506d608 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange2.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; +public class class1 implements interface1 +{ + property1: boolean; +} +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange3.js b/tests/baselines/reference/textChanges/replaceNodeRange3.js new file mode 100644 index 00000000000..a20dddc53fe --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange3.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} + // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange4.js b/tests/baselines/reference/textChanges/replaceNodeRange4.js new file mode 100644 index 00000000000..ad50a1f01fc --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange4.js @@ -0,0 +1,18 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1;public class class1 implements interface1 +{ + property1: boolean; +} // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceRange.js b/tests/baselines/reference/textChanges/replaceRange.js new file mode 100644 index 00000000000..8cb83286169 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceRange.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +public class class1 implements interface1 +{ + property1: boolean; +} +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js b/tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js new file mode 100644 index 00000000000..72a45ee56e2 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js @@ -0,0 +1,6 @@ +===ORIGINAL=== +const x = 1, y = "2"; +===MODIFIED=== +const x = 1, z1 = { + p1: 1 +}; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js b/tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js new file mode 100644 index 00000000000..304b81b1359 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 + public class class1 implements interface1 + { + property1: boolean; + } +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddForgottenThis01.ts b/tests/cases/fourslash/codeFixAddForgottenThis01.ts index 90d191b6ba5..07f06348212 100644 --- a/tests/cases/fourslash/codeFixAddForgottenThis01.ts +++ b/tests/cases/fourslash/codeFixAddForgottenThis01.ts @@ -2,9 +2,11 @@ ////class C { //// foo: number; -//// constructor() { -//// [|foo = 10|]; -//// } +//// constructor() {[| +//// foo = 10; +//// |]} ////} -verify.rangeAfterCodeFix("this.foo = 10"); \ No newline at end of file +verify.rangeAfterCodeFix(` + this.foo = 10; + `, /*includeWhitespace*/ true); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixSuperAfterThis.ts b/tests/cases/fourslash/codeFixSuperAfterThis.ts index 2bff98ceca0..55b44b07881 100644 --- a/tests/cases/fourslash/codeFixSuperAfterThis.ts +++ b/tests/cases/fourslash/codeFixSuperAfterThis.ts @@ -6,8 +6,10 @@ //// private a:number; //// constructor() {[| //// this.a = 12; -//// super();|] -//// } +//// super(); +//// |]} ////} - -verify.rangeAfterCodeFix("super(); this.a = 12;"); \ No newline at end of file +verify.rangeAfterCodeFix(` + super(); + this.a = 12; + `, /*includeWhiteSpace*/ true); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixSuperCall.ts b/tests/cases/fourslash/codeFixSuperCall.ts index c918e74dc38..f7584050a15 100644 --- a/tests/cases/fourslash/codeFixSuperCall.ts +++ b/tests/cases/fourslash/codeFixSuperCall.ts @@ -1,10 +1,11 @@ -/// +/// ////class Base{ ////} ////class C extends Base{ -//// constructor() {[| |] -//// } +//// constructor() {[| +//// |]} ////} - -verify.rangeAfterCodeFix('super();'); +verify.rangeAfterCodeFix(` + super(); + `, /*includeWhitespace*/ true); diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport10.ts b/tests/cases/fourslash/importNameCodeFixExistingImport10.ts index 25246e70123..8a178e72730 100644 --- a/tests/cases/fourslash/importNameCodeFixExistingImport10.ts +++ b/tests/cases/fourslash/importNameCodeFixExistingImport10.ts @@ -16,6 +16,6 @@ verify.importFixAtPosition([ `{ v1, v2, -f1 + f1 }` ]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport11.ts b/tests/cases/fourslash/importNameCodeFixExistingImport11.ts index 304ffb896df..8822356c13a 100644 --- a/tests/cases/fourslash/importNameCodeFixExistingImport11.ts +++ b/tests/cases/fourslash/importNameCodeFixExistingImport11.ts @@ -15,6 +15,7 @@ verify.importFixAtPosition([ `{ v1, v2, - v3, f1 + v3, + f1 }` ]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport9.ts b/tests/cases/fourslash/importNameCodeFixExistingImport9.ts index 05d17927454..51496abff12 100644 --- a/tests/cases/fourslash/importNameCodeFixExistingImport9.ts +++ b/tests/cases/fourslash/importNameCodeFixExistingImport9.ts @@ -11,7 +11,6 @@ verify.importFixAtPosition([ `{ - v1, -f1 + v1, f1 }` ]); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts index 288573608f2..7a63ff13caa 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace1.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -8,5 +8,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { - // some legit comments }`); diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts index 5aa3251c0b4..7f99863ba46 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -1,12 +1,16 @@ /// // @noUnusedLocals: true -//// function f1 () { -//// for (const elem of ["a", "b", "c"]) { -//// elem; -//// [|var x = 20; -//// }|] -////} +////function f1 () [|{ +//// for (const elem of ["a", "b", "c"]) { +//// elem; +//// var x = 20; +//// } +////}|] //// -verify.rangeAfterCodeFix("}"); +verify.rangeAfterCodeFix(`{ + for (const elem of ["a", "b", "c"]) { + elem; + } +}`, /*includeWhiteSpace*/ true); From 5040e1d279e12784ef3375b0acc27ba986054b82 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 16 Mar 2017 11:01:48 -0700 Subject: [PATCH 155/167] Mark occurence item in string with a special property (#14677) * mark occurence item in string with a special property * Adding trailing commas --- src/harness/fourslash.ts | 8 +++- .../unittests/tsserverProjectSystem.ts | 46 +++++++++++++++++++ src/server/protocol.ts | 5 ++ src/server/session.ts | 9 +++- src/services/documentHighlights.ts | 3 +- src/services/findAllReferences.ts | 4 +- src/services/services.ts | 3 +- src/services/types.ts | 2 + .../findAllRefsForStringLiteralTypes.ts | 4 +- .../fourslash/referencesForIndexProperty2.ts | 2 +- 10 files changed, 76 insertions(+), 10 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d7638ffc033..3507d0f7b71 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -928,9 +928,13 @@ namespace FourSlash { } function rangeToReferenceEntry(r: Range) { - let { isWriteAccess, isDefinition } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false }; + let { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined }; isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition; - return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }; + const result: any = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }; + if (isInString !== undefined) { + result.isInString = isInString; + } + return result; } } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 4d1b2a0b10c..a13835fa7f3 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3489,6 +3489,52 @@ namespace ts.projectSystem { }); }); + describe("occurence highlight on string", () => { + it("should be marked if only on string values", () => { + const file1: FileOrFolder = { + path: "/a/b/file1.ts", + content: `let t1 = "div";\nlet t2 = "div";\nlet t3 = { "div": 123 };\nlet t4 = t3["div"];` + }; + + const host = createServerHost([file1]); + const session = createSession(host); + const projectService = session.getProjectService(); + + projectService.openClientFile(file1.path); + { + const highlightRequest = makeSessionRequest( + CommandNames.Occurrences, + { file: file1.path, line: 1, offset: 11 } + ); + const highlightResponse = session.executeCommand(highlightRequest).response as protocol.OccurrencesResponseItem[]; + const firstOccurence = highlightResponse[0]; + assert.isTrue(firstOccurence.isInString, "Highlights should be marked with isInString"); + } + + { + const highlightRequest = makeSessionRequest( + CommandNames.Occurrences, + { file: file1.path, line: 3, offset: 13 } + ); + const highlightResponse = session.executeCommand(highlightRequest).response as protocol.OccurrencesResponseItem[]; + assert.isTrue(highlightResponse.length === 2); + const firstOccurence = highlightResponse[0]; + assert.isUndefined(firstOccurence.isInString, "Highlights should not be marked with isInString if on property name"); + } + + { + const highlightRequest = makeSessionRequest( + CommandNames.Occurrences, + { file: file1.path, line: 4, offset: 14 } + ); + const highlightResponse = session.executeCommand(highlightRequest).response as protocol.OccurrencesResponseItem[]; + assert.isTrue(highlightResponse.length === 2); + const firstOccurence = highlightResponse[0]; + assert.isUndefined(firstOccurence.isInString, "Highlights should not be marked with isInString if on indexer"); + } + }); + }); + describe("maxNodeModuleJsDepth for inferred projects", () => { it("should be set to 2 if the project has js root files", () => { const file1: FileOrFolder = { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index d12aa2e0a48..5096eefc1fc 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -621,6 +621,11 @@ namespace ts.server.protocol { * True if the occurrence is a write location, false otherwise. */ isWriteAccess: boolean; + + /** + * True if the occurrence is in a string, undefined otherwise; + */ + isInString?: true; } export interface OccurrencesResponse extends Response { diff --git a/src/server/session.ts b/src/server/session.ts index 64fce61a095..f82d11ba91b 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -651,16 +651,21 @@ namespace ts.server { } return occurrences.map(occurrence => { - const { fileName, isWriteAccess, textSpan } = occurrence; + const { fileName, isWriteAccess, textSpan, isInString } = occurrence; const scriptInfo = project.getScriptInfo(fileName); const start = scriptInfo.positionToLineOffset(textSpan.start); const end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { + const result: protocol.OccurrencesResponseItem = { start, end, file: fileName, isWriteAccess, }; + // no need to serialize the property if it is not true + if (isInString) { + result.isInString = isInString; + } + return result; }); } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index ff2b819ec26..502dfc59825 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -37,7 +37,8 @@ namespace ts.DocumentHighlights { documentHighlights.highlightSpans.push({ textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference + kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference, + isInString: referenceEntry.isInString }); } } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index bc1e50391c8..9e5eb0351cc 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1044,7 +1044,9 @@ namespace ts.FindAllReferences { const type = getStringLiteralTypeForNode(node, typeChecker); if (type === searchType) { - references.push(getReferenceEntryFromNode(node)); + const reference = getReferenceEntryFromNode(node); + reference.isInString = true; + references.push(reference); } } } diff --git a/src/services/services.ts b/src/services/services.ts index e370dccac32..a2931a39ab0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1396,7 +1396,8 @@ namespace ts { fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference, - isDefinition: false + isDefinition: false, + isInString: highlightSpan.isInString, }); } } diff --git a/src/services/types.ts b/src/services/types.ts index 149bb4340dc..3e5d31b586b 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -364,6 +364,7 @@ namespace ts { fileName: string; isWriteAccess: boolean; isDefinition: boolean; + isInString?: true; } export interface ImplementationLocation { @@ -385,6 +386,7 @@ namespace ts { export interface HighlightSpan { fileName?: string; + isInString?: true; textSpan: TextSpan; kind: string; } diff --git a/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts b/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts index e450102c127..312bce4a3ad 100644 --- a/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts +++ b/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts @@ -1,6 +1,6 @@ /// -////type Options = "[|option 1|]" | "option 2"; -////let myOption: Options = "[|option 1|]"; +////type Options = "[|{| "isInString": true |}option 1|]" | "option 2"; +////let myOption: Options = "[|{| "isInString": true |}option 1|]"; verify.singleReferenceGroup('"option 1"'); diff --git a/tests/cases/fourslash/referencesForIndexProperty2.ts b/tests/cases/fourslash/referencesForIndexProperty2.ts index a4d5c75a908..0f87c82f7d3 100644 --- a/tests/cases/fourslash/referencesForIndexProperty2.ts +++ b/tests/cases/fourslash/referencesForIndexProperty2.ts @@ -3,6 +3,6 @@ // References to a unknown index property ////var a; -////a["[|blah|]"]; +////a["[|{| "isInString": true |}blah|]"]; verify.singleReferenceGroup('"blah"'); From 9c0f77091c0b956282a33e101ec6c9173a9c201e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 7 Mar 2017 06:42:50 -0800 Subject: [PATCH 156/167] Clean up code in parser --- src/compiler/parser.ts | 52 +++++++++++++++++++++++------------------- src/compiler/types.ts | 3 +-- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 308d3a317f9..6db26355d92 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1309,7 +1309,7 @@ namespace ts { case ParsingContext.ObjectBindingElements: return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.DotDotDotToken || isLiteralPropertyName(); case ParsingContext.HeritageClauseElement: - // If we see { } then only consume it as an expression if it is followed by , or { + // If we see { } then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. if (token() === SyntaxKind.OpenBraceToken) { return lookAhead(isValidHeritageClauseObjectLiteral); @@ -2113,7 +2113,7 @@ namespace ts { return finishNode(node); } - function parseTypeParameters(): NodeArray { + function parseTypeParameters(): NodeArray | undefined { if (token() === SyntaxKind.LessThanToken) { return parseBracketedList(ParsingContext.TypeParameters, parseTypeParameter, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); } @@ -2183,7 +2183,7 @@ namespace ts { } function fillSignature( - returnToken: SyntaxKind, + returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, yieldContext: boolean, awaitContext: boolean, requireCompleteParameterList: boolean, @@ -2373,14 +2373,14 @@ namespace ts { } function isTypeMemberStart(): boolean { - let idToken: SyntaxKind; // Return true if we have the start of a signature member if (token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken) { return true; } + let idToken: boolean; // Eat up all modifiers, but hold on to the last one in case it is actually an identifier while (isModifierKind(token())) { - idToken = token(); + idToken = true; nextToken(); } // Index signatures and computed property names are type members @@ -2389,7 +2389,7 @@ namespace ts { } // Try to get the first property-like token following all modifiers if (isLiteralPropertyName()) { - idToken = token(); + idToken = true; nextToken(); } // If we were able to get any potential identifier, check that it is @@ -2497,7 +2497,7 @@ namespace ts { return finishNode(node); } - function parseKeywordAndNoDot(): TypeNode { + function parseKeywordAndNoDot(): TypeNode | undefined { const node = parseTokenNode(); return token() === SyntaxKind.DotToken ? undefined : node; } @@ -2635,7 +2635,7 @@ namespace ts { return parseArrayTypeOrHigher(); } - function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode { + function parseUnionOrIntersectionType(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, parseConstituentType: () => TypeNode, operator: SyntaxKind.BarToken | SyntaxKind.AmpersandToken): TypeNode { parseOptional(operator); let type = parseConstituentType(); if (token() === operator) { @@ -5281,8 +5281,8 @@ namespace ts { * * In such situations, 'permitInvalidConstAsModifier' should be set to true. */ - function parseModifiers(permitInvalidConstAsModifier?: boolean): NodeArray { - let modifiers: NodeArray; + function parseModifiers(permitInvalidConstAsModifier?: boolean): NodeArray | undefined { + let modifiers: NodeArray | undefined; while (true) { const modifierStart = scanner.getStartPos(); const modifierKind = token(); @@ -5422,7 +5422,7 @@ namespace ts { return token() === SyntaxKind.ImplementsKeyword && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(): NodeArray { + function parseHeritageClauses(): NodeArray | undefined { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } @@ -5433,7 +5433,7 @@ namespace ts { return undefined; } - function parseHeritageClause() { + function parseHeritageClause(): HeritageClause | undefined { if (token() === SyntaxKind.ExtendsKeyword || token() === SyntaxKind.ImplementsKeyword) { const node = createNode(SyntaxKind.HeritageClause); node.token = token(); @@ -5459,7 +5459,7 @@ namespace ts { return token() === SyntaxKind.ExtendsKeyword || token() === SyntaxKind.ImplementsKeyword; } - function parseClassMembers() { + function parseClassMembers(): NodeArray { return parseList(ParsingContext.ClassMembers, parseClassElement); } @@ -5618,17 +5618,7 @@ namespace ts { if (isIdentifier()) { identifier = parseIdentifier(); if (token() !== SyntaxKind.CommaToken && token() !== SyntaxKind.FromKeyword) { - // ImportEquals declaration of type: - // import x = require("mod"); or - // import x = M.x; - const importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); - importEqualsDeclaration.decorators = decorators; - importEqualsDeclaration.modifiers = modifiers; - importEqualsDeclaration.name = identifier; - parseExpected(SyntaxKind.EqualsToken); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return addJSDocComment(finishNode(importEqualsDeclaration)); + return parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier); } } @@ -5652,6 +5642,20 @@ namespace ts { return finishNode(importDeclaration); } + function parseImportEqualsDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray, identifier: ts.Identifier): ImportEqualsDeclaration { + // ImportEquals declaration of type: + // import x = require("mod"); or + // import x = M.x; + const importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); + importEqualsDeclaration.decorators = decorators; + importEqualsDeclaration.modifiers = modifiers; + importEqualsDeclaration.name = identifier; + parseExpected(SyntaxKind.EqualsToken); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return addJSDocComment(finishNode(importEqualsDeclaration)); + } + function parseImportClause(identifier: Identifier, fullStart: number) { // ImportClause: // ImportedDefaultBinding diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 86895f3db6e..7728c2b8519 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1813,7 +1813,7 @@ namespace ts { kind: SyntaxKind.ModuleDeclaration; parent?: ModuleBody | SourceFile; name: ModuleName; - body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; + body?: ModuleBody | JSDocNamespaceDeclaration; } export type NamespaceBody = ModuleBlock | NamespaceDeclaration; @@ -1889,7 +1889,6 @@ namespace ts { export interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; - moduleReference: LiteralLikeNode; } export interface ExportDeclaration extends DeclarationStatement { From 18f283f68adbeeca78d70c6c7474eda46133a545 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 16 Mar 2017 14:43:56 -0700 Subject: [PATCH 157/167] Add more missing quotes --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6db26355d92..f5c4d880072 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1309,7 +1309,7 @@ namespace ts { case ParsingContext.ObjectBindingElements: return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.DotDotDotToken || isLiteralPropertyName(); case ParsingContext.HeritageClauseElement: - // If we see { } then only consume it as an expression if it is followed by `,` or `{` + // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. if (token() === SyntaxKind.OpenBraceToken) { return lookAhead(isValidHeritageClauseObjectLiteral); From 595342615b8e9c729626668f3a1eff3c764fb77b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 16 Mar 2017 15:53:05 -0700 Subject: [PATCH 158/167] abstract code in FindReferences from concrete way of creating result reference entry to seamlessly reuse the same code for gotoImplementation (#14637) --- src/harness/fourslash.ts | 28 +++ src/server/client.ts | 4 +- src/services/documentHighlights.ts | 3 +- src/services/findAllReferences.ts | 181 +++++++++++------- src/services/goToImplementation.ts | 12 +- src/services/types.ts | 22 ++- .../goToImplementationClassMethod_00.ts | 2 +- .../goToImplementationInterface_00.ts | 4 +- .../goToImplementationInterface_07.ts | 2 + 9 files changed, 172 insertions(+), 86 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 3507d0f7b71..8ef4d946694 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1859,17 +1859,41 @@ namespace FourSlash { const unsatisfiedRanges: Range[] = []; + const delayedErrors: string[] = []; for (const range of ranges) { const length = range.end - range.start; const matchingImpl = ts.find(implementations, impl => range.fileName === impl.fileName && range.start === impl.textSpan.start && length === impl.textSpan.length); if (matchingImpl) { + if (range.marker && range.marker.data) { + const expected = <{ displayParts?: ts.SymbolDisplayPart[], parts: string[], kind?: string }>range.marker.data; + if (expected.displayParts) { + if (!ts.arrayIsEqualTo(expected.displayParts, matchingImpl.displayParts, displayPartIsEqualTo)) { + delayedErrors.push(`Mismatched display parts: expected ${JSON.stringify(expected.displayParts)}, actual ${JSON.stringify(matchingImpl.displayParts)}`); + } + } + else if (expected.parts) { + const actualParts = matchingImpl.displayParts.map(p => p.text); + if (!ts.arrayIsEqualTo(expected.parts, actualParts)) { + delayedErrors.push(`Mismatched non-tagged display parts: expected ${JSON.stringify(expected.parts)}, actual ${JSON.stringify(actualParts)}`); + } + } + if (expected.kind !== undefined) { + if (expected.kind !== matchingImpl.kind) { + delayedErrors.push(`Mismatched kind: expected ${JSON.stringify(expected.kind)}, actual ${JSON.stringify(matchingImpl.kind)}`); + } + } + } + matchingImpl.matched = true; } else { unsatisfiedRanges.push(range); } } + if (delayedErrors.length) { + this.raiseError(delayedErrors.join("\n")); + } const unmatchedImplementations = implementations.filter(impl => !impl.matched); if (unmatchedImplementations.length || unsatisfiedRanges.length) { @@ -1894,6 +1918,10 @@ namespace FourSlash { function implementationsAreEqual(a: ImplementationLocationInformation, b: ImplementationLocationInformation) { return a.fileName === b.fileName && TestState.textSpansEqual(a.textSpan, b.textSpan); } + + function displayPartIsEqualTo(a: ts.SymbolDisplayPart, b: ts.SymbolDisplayPart): boolean { + return a.kind === b.kind && a.text === b.text; + } } public getMarkers(): Marker[] { diff --git a/src/server/client.ts b/src/server/client.ts index 6f784db1682..8e81a423837 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -382,7 +382,9 @@ namespace ts.server { const end = this.lineOffsetToPosition(fileName, entry.end); return { fileName, - textSpan: ts.createTextSpanFromBounds(start, end) + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ScriptElementKind.unknown, + displayParts: [] }; }); } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 502dfc59825..7308ad235fc 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -17,7 +17,8 @@ namespace ts.DocumentHighlights { } function getSemanticDocumentHighlights(node: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] { - const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + const context = new FindAllReferences.DefaultFindReferencesContext(typeChecker, cancellationToken); + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(context, node, sourceFilesToSearch); return referencedSymbols && convertReferencedSymbols(referencedSymbols); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 9e5eb0351cc..725b9b99506 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1,21 +1,75 @@ /* @internal */ namespace ts.FindAllReferences { + + export interface FindReferencesContext { + readonly typeChecker: TypeChecker; + readonly cancellationToken: CancellationToken; + getReferenceEntryFromNode(node: Node, isInString?: boolean): T; + getReferenceEntryForSpanInFile(fileName: string, span: TextSpan): T; + } + + export class DefaultFindReferencesContext implements FindReferencesContext { + constructor(readonly typeChecker: TypeChecker, readonly cancellationToken: CancellationToken) { + } + getReferenceEntryFromNode(node: Node, isInString?: boolean): ReferenceEntry { + const reference = getReferenceEntryFromNode(node); + if (isInString) { + reference.isInString = true; + } + return reference; + } + getReferenceEntryForSpanInFile(fileName: string, textSpan: TextSpan): ReferenceEntry { + return { textSpan, fileName, isWriteAccess: false, isDefinition: false }; + } + } + + export class FindImplementationsContext implements FindReferencesContext { + constructor(readonly typeChecker: TypeChecker, readonly cancellationToken: CancellationToken) { + } + getReferenceEntryFromNode(node: Node): ImplementationLocation { + const entry = getReferenceEntryFromNode(node); + const symbol = this.typeChecker.getSymbolAtLocation(isDeclaration(node) && node.name ? node.name : node); + if (symbol) { + const def = getDefinition(symbol, node, this.typeChecker); + entry.kind = def.kind; + entry.displayParts = def.displayParts; + } + else if (node.kind === SyntaxKind.ObjectLiteralExpression) { + entry.kind = ScriptElementKind.interfaceElement; + entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)] + } + else if (node.kind === SyntaxKind.ClassExpression) { + entry.kind = ScriptElementKind.localClassElement; + entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)] + } + else { + entry.kind = getNodeKind(node); + entry.displayParts = []; + } + return entry; + } + getReferenceEntryForSpanInFile(fileName: string, textSpan: TextSpan): ImplementationLocation { + return { textSpan, fileName, kind: ScriptElementKind.unknown, displayParts: [] }; + } + } + export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean, isForRename: boolean): ReferencedSymbol[] | undefined { const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); + return getReferencedSymbolsForNode(new DefaultFindReferencesContext(typeChecker, cancellationToken), node, sourceFiles, findInStrings, findInComments, isForRename); } export function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[] { return referenceSymbols && flatMap(referenceSymbols, r => r.references); } - export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings?: boolean, findInComments?: boolean, isForRename?: boolean, implementations?: boolean): ReferencedSymbol[] | undefined { + export function getReferencedSymbolsForNode(context: FindReferencesContext, node: Node, sourceFiles: SourceFile[], findInStrings?: boolean, findInComments?: boolean, isForRename?: boolean, implementations?: boolean): ReferencedSymbolOf[] | undefined { if (!implementations) { - const special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + const special = getReferencedSymbolsSpecial(node, sourceFiles, context); if (special) { return special; } } + const { typeChecker, cancellationToken } = context; // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, // so we have to specify that we want the constructor symbol. @@ -24,7 +78,7 @@ namespace ts.FindAllReferences { // Could not find a symbol e.g. unknown identifier if (!symbol) { if (!implementations && node.kind === SyntaxKind.StringLiteral) { - return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + return getReferencesForStringLiteral(node, sourceFiles, context); } // Can't have references to something that we have no symbol for. return undefined; @@ -49,7 +103,7 @@ namespace ts.FindAllReferences { // Compute the meaning from the location and the symbol it references const searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - const result: ReferencedSymbol[] = []; + const result: ReferencedSymbolOf[] = []; // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. const symbolToIndex: number[] = []; const inheritsFromCache: Map = createMap(); @@ -81,14 +135,14 @@ namespace ts.FindAllReferences { function getRefs(scope: ts.Node, searchName: string): void { getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, - symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); + symbolToIndex, implementations, context, searchSymbols, inheritsFromCache); } } /** getReferencedSymbols for special node kinds. */ - function getReferencedSymbolsSpecial(node: Node, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] | undefined { + function getReferencedSymbolsSpecial(node: Node, sourceFiles: SourceFile[], context: FindReferencesContext): ReferencedSymbolOf[] | undefined { if (isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + return getAllReferencesForKeyword(context, sourceFiles, node.kind); } // Labels @@ -97,20 +151,20 @@ namespace ts.FindAllReferences { const labelDefinition = getTargetLabel((node.parent), (node).text); // if we have a label definition, look within its statement for references, if not, then // the label is undefined and we have no results.. - return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, context); } else { // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node, cancellationToken); + return getLabelReferencesInNode(node.parent, node, context); } } if (isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + return getReferencesForThisKeyword(node, sourceFiles, context); } if (node.kind === SyntaxKind.SuperKeyword) { - return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + return getReferencesForSuperKeyword(node, context); } return undefined; @@ -352,10 +406,11 @@ namespace ts.FindAllReferences { return positions; } - function getLabelReferencesInNode(container: Node, targetLabel: Identifier, cancellationToken: CancellationToken): ReferencedSymbol[] { - const references: ReferenceEntry[] = []; + function getLabelReferencesInNode(container: Node, targetLabel: Identifier, context: FindReferencesContext): ReferencedSymbolOf[] { + const references: T[] = []; const sourceFile = container.getSourceFile(); const labelName = targetLabel.text; + const { cancellationToken } = context; const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); forEach(possiblePositions, position => { cancellationToken.throwIfCancellationRequested(); @@ -368,7 +423,7 @@ namespace ts.FindAllReferences { // Only pick labels that are either the target label, or have a target that is the target label if (node === targetLabel || (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); + references.push(context.getReferenceEntryFromNode(node)); } }); @@ -404,12 +459,13 @@ namespace ts.FindAllReferences { } } - function getAllReferencesForKeyword(sourceFiles: SourceFile[], keywordKind: ts.SyntaxKind, cancellationToken: CancellationToken): ReferencedSymbol[] { + function getAllReferencesForKeyword(context: FindReferencesContext, sourceFiles: SourceFile[], keywordKind: ts.SyntaxKind): ReferencedSymbolOf[] { + const { cancellationToken } = context; const name = tokenToString(keywordKind); - const references: ReferenceEntry[] = []; + const references: T[] = []; for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); - addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, context, references); } if (!references.length) return undefined; @@ -427,18 +483,14 @@ namespace ts.FindAllReferences { return [{ definition, references }]; } - function addReferencesForKeywordInFile(sourceFile: SourceFile, kind: SyntaxKind, searchText: string, cancellationToken: CancellationToken, references: Push): void { + function addReferencesForKeywordInFile(sourceFile: SourceFile, kind: SyntaxKind, searchText: string, context: FindReferencesContext, references: Push): void { + const { cancellationToken } = context; const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); for (const position of possiblePositions) { cancellationToken.throwIfCancellationRequested(); const referenceLocation = getTouchingPropertyName(sourceFile, position); if (referenceLocation.kind === kind) { - references.push({ - textSpan: createTextSpanFromNode(referenceLocation), - fileName: sourceFile.fileName, - isWriteAccess: false, - isDefinition: false, - }); + references.push(context.getReferenceEntryForSpanInFile(sourceFile.fileName, createTextSpanFromNode(referenceLocation))); } } } @@ -447,22 +499,22 @@ namespace ts.FindAllReferences { * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). * searchLocation: a node where the search value */ - function getReferencesInNode(container: Node, + function getReferencesInNode(container: Node, searchSymbol: Symbol, searchText: string, searchLocation: Node, searchMeaning: SemanticMeaning, findInStrings: boolean, findInComments: boolean, - result: ReferencedSymbol[], + result: ReferencedSymbolOf[], symbolToIndex: number[], implementations: boolean, - typeChecker: TypeChecker, - cancellationToken: CancellationToken, + context: FindReferencesContext, searchSymbols: Symbol[], inheritsFromCache: Map): void { const sourceFile = container.getSourceFile(); + const { typeChecker, cancellationToken } = context; const start = findInComments ? container.getFullStart() : container.getStart(); const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); @@ -486,12 +538,7 @@ namespace ts.FindAllReferences { // 'FindReferences' will just filter out these results. result.push({ definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] + references: [context.getReferenceEntryForSpanInFile(sourceFile.fileName, createTextSpan(position, searchText.length))] }); } continue; @@ -571,11 +618,11 @@ namespace ts.FindAllReferences { function addReferences(references: Node[]): void { if (references.length) { const referencedSymbol = getReferencedSymbol(searchSymbol); - addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode)); + addRange(referencedSymbol.references, map(references, n => context.getReferenceEntryFromNode(n))); } } - function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { + function getReferencedSymbol(symbol: Symbol): ReferencedSymbolOf { const symbolId = getSymbolId(symbol); let index = symbolToIndex[symbolId]; if (index === undefined) { @@ -594,10 +641,10 @@ namespace ts.FindAllReferences { function addReferenceToRelatedSymbol(node: Node, relatedSymbol: Symbol) { const references = getReferencedSymbol(relatedSymbol).references; if (implementations) { - getImplementationReferenceEntryForNode(node, references, typeChecker); + getImplementationReferenceEntryForNode(node, references, context); } else { - references.push(getReferenceEntryFromNode(node)); + references.push(context.getReferenceEntryFromNode(node)); } } } @@ -658,21 +705,21 @@ namespace ts.FindAllReferences { return result; } - function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[], typeChecker: TypeChecker): void { + function getImplementationReferenceEntryForNode(refNode: Node, result: T[], context: FindReferencesContext): void { // Check if we found a function/propertyAssignment/method with an implementation or initializer if (isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); + result.push(context.getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === SyntaxKind.Identifier) { if (refNode.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + getReferenceEntriesForShorthandPropertyAssignment(refNode, context, result); } // Check if the node is within an extends or implements clause const containingClass = getContainingClassIfInHeritageClause(refNode); if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); + result.push(context.getReferenceEntryFromNode(containingClass)); return; } @@ -681,22 +728,22 @@ namespace ts.FindAllReferences { if (containingTypeReference) { const parent = containingTypeReference.parent; if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent.initializer)); + maybeAdd(context.getReferenceEntryFromNode(parent.initializer)); } else if (isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { if (parent.body.kind === SyntaxKind.Block) { forEachReturnStatement(parent.body, returnStatement => { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + maybeAdd(context.getReferenceEntryFromNode(returnStatement.expression)); } }); } else if (isImplementationExpression(parent.body)) { - maybeAdd(getReferenceEntryFromNode(parent.body)); + maybeAdd(context.getReferenceEntryFromNode(parent.body)); } } else if (isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - maybeAdd(getReferenceEntryFromNode(parent.expression)); + maybeAdd(context.getReferenceEntryFromNode(parent.expression)); } } } @@ -706,7 +753,7 @@ namespace ts.FindAllReferences { // Because we are returning the implementation locations and not the identifier locations, // duplicate entries would be returned here as each of the type references is part of // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a: ReferenceEntry) { + function maybeAdd(a: T) { if (!forEach(result, b => a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length)) { result.push(a); } @@ -845,7 +892,7 @@ namespace ts.FindAllReferences { } } - function getReferencesForSuperKeyword(superKeyword: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + function getReferencesForSuperKeyword(superKeyword: Node, context: FindReferencesContext): ReferencedSymbolOf[] { let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); if (!searchSpaceNode) { return undefined; @@ -868,7 +915,8 @@ namespace ts.FindAllReferences { return undefined; } - const references: ReferenceEntry[] = []; + const references: T[] = []; + const { typeChecker, cancellationToken } = context; const sourceFile = searchSpaceNode.getSourceFile(); const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); @@ -887,7 +935,7 @@ namespace ts.FindAllReferences { // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. if (container && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + references.push(context.getReferenceEntryFromNode(node)); } } @@ -895,8 +943,9 @@ namespace ts.FindAllReferences { return [{ definition, references }]; } - function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[], context: FindReferencesContext): ReferencedSymbolOf[] { let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + const { typeChecker, cancellationToken } = context; // Whether 'this' occurs in a static context within a class. let staticFlag = ModifierFlags.Static; @@ -930,7 +979,7 @@ namespace ts.FindAllReferences { return undefined; } - const references: ReferenceEntry[] = []; + const references: T[] = []; let possiblePositions: number[]; if (searchSpaceNode.kind === SyntaxKind.SourceFile) { @@ -963,7 +1012,7 @@ namespace ts.FindAllReferences { references: references }]; - function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: ReferenceEntry[]): void { + function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: T[]): void { forEach(possiblePositions, position => { cancellationToken.throwIfCancellationRequested(); @@ -978,13 +1027,13 @@ namespace ts.FindAllReferences { case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); + result.push(context.getReferenceEntryFromNode(node)); } break; case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); + result.push(context.getReferenceEntryFromNode(node)); } break; case SyntaxKind.ClassExpression: @@ -992,12 +1041,12 @@ namespace ts.FindAllReferences { // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); + result.push(context.getReferenceEntryFromNode(node)); } break; case SyntaxKind.SourceFile: if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); + result.push(context.getReferenceEntryFromNode(node)); } break; } @@ -1005,7 +1054,8 @@ namespace ts.FindAllReferences { } } - function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[], context: FindReferencesContext): ReferencedSymbolOf[] { + const { typeChecker, cancellationToken } = context; const type = getStringLiteralTypeForNode(node, typeChecker); if (!type) { @@ -1013,7 +1063,7 @@ namespace ts.FindAllReferences { return undefined; } - const references: ReferenceEntry[] = []; + const references: T[] = []; for (const sourceFile of sourceFiles) { const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); @@ -1033,7 +1083,7 @@ namespace ts.FindAllReferences { references: references }]; - function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: ReferenceEntry[]): void { + function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: T[]): void { for (const position of possiblePositions) { cancellationToken.throwIfCancellationRequested(); @@ -1044,9 +1094,7 @@ namespace ts.FindAllReferences { const type = getStringLiteralTypeForNode(node, typeChecker); if (type === searchType) { - const reference = getReferenceEntryFromNode(node); - reference.isInString = true; - references.push(reference); + references.push(context.getReferenceEntryFromNode(node, /*isInString*/ true)); } } } @@ -1359,14 +1407,15 @@ namespace ts.FindAllReferences { } } - export function getReferenceEntriesForShorthandPropertyAssignment(node: Node, typeChecker: TypeChecker, result: ReferenceEntry[]): void { + export function getReferenceEntriesForShorthandPropertyAssignment(node: Node, context: FindReferencesContext, result: T[]): void { + const { typeChecker } = context; const refSymbol = typeChecker.getSymbolAtLocation(node); const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); if (shorthandSymbol) { for (const declaration of shorthandSymbol.getDeclarations()) { if (getMeaningFromDeclaration(declaration) & SemanticMeaning.Value) { - result.push(getReferenceEntryFromNode(declaration)); + result.push(context.getReferenceEntryFromNode(declaration)); } } } diff --git a/src/services/goToImplementation.ts b/src/services/goToImplementation.ts index 9135e1fe0f0..dd3c06174af 100644 --- a/src/services/goToImplementation.ts +++ b/src/services/goToImplementation.ts @@ -1,25 +1,25 @@ /* @internal */ namespace ts.GoToImplementation { export function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[] { + const context = new FindAllReferences.FindImplementationsContext(typeChecker, cancellationToken); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { - const result: ReferenceEntry[] = []; - FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); + const result: ImplementationLocation[] = []; + FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, context, result); return result.length > 0 ? result : undefined; } else if (node.kind === SyntaxKind.SuperKeyword || isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" const symbol = typeChecker.getSymbolAtLocation(node); - return symbol.valueDeclaration && [FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; + return symbol.valueDeclaration && [context.getReferenceEntryFromNode(symbol.valueDeclaration)]; } else { // Perform "Find all References" and retrieve only those that are implementations - const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(context, node, sourceFiles, /*findInStrings*/false, /*findInComments*/false, /*isForRename*/false, /*implementations*/true); - const result = flatMap(referencedSymbols, symbol => - map(symbol.references, ({ textSpan, fileName }) => ({ textSpan, fileName }))); + const result = flatMap(referencedSymbols, symbol => symbol.references); return result && result.length > 0 ? result : undefined; } diff --git a/src/services/types.ts b/src/services/types.ts index 3e5d31b586b..856b03330bf 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -354,22 +354,23 @@ namespace ts { caretOffset: number; } - export interface RenameLocation { + export interface DocumentSpan { textSpan: TextSpan; fileName: string; } - export interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; + export interface RenameLocation extends DocumentSpan { + } + + export interface ReferenceEntry extends DocumentSpan { isWriteAccess: boolean; isDefinition: boolean; isInString?: true; } - export interface ImplementationLocation { - textSpan: TextSpan; - fileName: string; + export interface ImplementationLocation extends DocumentSpan { + kind: string; + displayParts: SymbolDisplayPart[]; } export interface DocumentHighlights { @@ -478,9 +479,12 @@ namespace ts { displayParts: SymbolDisplayPart[]; } - export interface ReferencedSymbol { + export interface ReferencedSymbolOf { definition: ReferencedSymbolDefinitionInfo; - references: ReferenceEntry[]; + references: T[]; + } + + export interface ReferencedSymbol extends ReferencedSymbolOf { } export enum SymbolDisplayPartKind { diff --git a/tests/cases/fourslash/goToImplementationClassMethod_00.ts b/tests/cases/fourslash/goToImplementationClassMethod_00.ts index 6fc8d9bf7cc..09bece0c1a2 100644 --- a/tests/cases/fourslash/goToImplementationClassMethod_00.ts +++ b/tests/cases/fourslash/goToImplementationClassMethod_00.ts @@ -3,7 +3,7 @@ // Should handle calls made on members declared in a class //// class Bar { -//// [|hello() {}|] +//// [|{|"parts": ["(","method",")"," ","Bar",".","hello","(",")",":"," ","void"], "kind": "method"|}hello() {}|] //// } //// //// new Bar().hel/*reference*/lo; diff --git a/tests/cases/fourslash/goToImplementationInterface_00.ts b/tests/cases/fourslash/goToImplementationInterface_00.ts index 8fc36b4bab5..33ff9fbd045 100644 --- a/tests/cases/fourslash/goToImplementationInterface_00.ts +++ b/tests/cases/fourslash/goToImplementationInterface_00.ts @@ -8,12 +8,12 @@ //// //// interface Baz extends Foo {} //// -//// var bar: Foo = [|{ hello: helloImpl /**0*/ }|]; +//// var bar: Foo = [|{|"parts": ["(","object literal",")"], "kind": "interface"|}{ hello: helloImpl /**0*/ }|]; //// var baz: Foo[] = [|[{ hello: helloImpl /**4*/ }]|]; //// //// function helloImpl () {} //// -//// function whatever(x: Foo = [|{ hello() {/**1*/} }|] ) { +//// function whatever(x: Foo = [|{|"parts": ["(","object literal",")"], "kind": "interface"|}{ hello() {/**1*/} }|] ) { //// } //// //// class Bar { diff --git a/tests/cases/fourslash/goToImplementationInterface_07.ts b/tests/cases/fourslash/goToImplementationInterface_07.ts index 6d874b3dc76..960072004b4 100644 --- a/tests/cases/fourslash/goToImplementationInterface_07.ts +++ b/tests/cases/fourslash/goToImplementationInterface_07.ts @@ -19,6 +19,8 @@ //// let x7: (new() => Foo) = [|class { hello () { /**constructorType*/} }|]; //// let x8: Foo[] = [|[{ hello () { /**arrayType*/} }]|]; //// let x9: { y: Foo } = [|{ y: { hello () { /**typeLiteral*/} } }|]; +//// let x10 = [|{|"parts": ["(","anonymous local class",")"], "kind": "local class"|}class implements Foo { hello() {} }|] +//// let x11 = [|{|"parts": ["(","local class",")"," ","C"], "kind": "local class"|}class C implements Foo { hello() {} }|] //// //// // Should not do anything for type predicates //// function isFoo(a: any): a is Foo { From 2ff19f492b762b022d46c575a0c35f1d8cb15f06 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 17 Mar 2017 11:22:01 -0700 Subject: [PATCH 159/167] Update the logo to the one which our website uses. --- doc/logo.svg | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/doc/logo.svg b/doc/logo.svg index fc7e0fadd66..2c0dd017a1b 100644 --- a/doc/logo.svg +++ b/doc/logo.svg @@ -1,15 +1,10 @@ - - - - - - - - - - - - - - - + + + + + \ No newline at end of file From 2305c10a651390c71c6f4edc2454c10e99cb11bd Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 17 Mar 2017 13:37:12 -0700 Subject: [PATCH 160/167] Fix lint errors --- src/compiler/moduleNameResolver.ts | 2 +- src/compiler/program.ts | 6 +- src/harness/fourslash.ts | 10 +-- .../formatting/getFormattingEditsForRange.ts | 88 ------------------- src/harness/unittests/textChanges.ts | 33 +++---- src/lib/dom.iterable.d.ts | 24 +++-- src/lib/es2015.collection.d.ts | 2 +- src/lib/es2015.core.d.ts | 6 +- src/lib/es2015.iterable.d.ts | 2 +- src/lib/es2015.proxy.d.ts | 4 +- src/lib/es2015.symbol.d.ts | 10 +-- src/lib/es2015.symbol.wellknown.d.ts | 54 ++++++------ src/lib/es2017.sharedmemory.d.ts | 4 +- src/lib/es2017.string.d.ts | 54 ++++++------ src/lib/es5.d.ts | 18 ++-- src/lib/scripthost.d.ts | 2 +- src/lib/webworker.importscripts.d.ts | 4 +- src/server/builder.ts | 2 +- src/server/client.ts | 2 +- src/server/server.ts | 10 +-- .../typingsInstaller/nodeTypingsInstaller.ts | 2 +- src/services/codefixes/importFixes.ts | 3 +- src/services/findAllReferences.ts | 4 +- src/services/textChanges.ts | 14 +-- ...ariableDeclarationInStrictMode1.errors.txt | 2 +- tslint.json | 3 +- 26 files changed, 139 insertions(+), 226 deletions(-) delete mode 100644 src/harness/unittests/services/formatting/getFormattingEditsForRange.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 1911605a0a6..699919e0566 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e117761a3a3..cffb6df1e3d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -298,8 +298,8 @@ namespace ts { let noDiagnosticsTypeChecker: TypeChecker; let classifiableNames: Map; - let cachedSemanticDiagnosticsForFile: DiagnosticCache = {}; - let cachedDeclarationDiagnosticsForFile: DiagnosticCache = {}; + const cachedSemanticDiagnosticsForFile: DiagnosticCache = {}; + const cachedDeclarationDiagnosticsForFile: DiagnosticCache = {}; let resolvedTypeReferenceDirectives = createMap(); let fileProcessingDiagnostics = createDiagnosticCollection(); @@ -1105,7 +1105,7 @@ namespace ts { return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache); } - function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile| undefined, cancellationToken: CancellationToken) { + function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile | undefined, cancellationToken: CancellationToken) { return runWithCancellationToken(() => { const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8ef4d946694..092c84996f1 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -927,12 +927,11 @@ namespace FourSlash { this.assertObjectsEqual(fullActual, fullExpected); } - function rangeToReferenceEntry(r: Range) { - let { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined }; - isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition; - const result: any = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }; + function rangeToReferenceEntry(r: Range): ts.ReferenceEntry { + const { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined }; + const result: ts.ReferenceEntry = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess: !!isWriteAccess, isDefinition: !!isDefinition }; if (isInString !== undefined) { - result.isInString = isInString; + result.isInString = isInString } return result; } @@ -2291,7 +2290,6 @@ namespace FourSlash { else { if (actual === undefined) { this.raiseError(`${name} failed - expected the template {newText: "${expected.newText}", caretOffset: "${expected.caretOffset}"} but got nothing instead`); - } if (actual.newText !== expected.newText) { diff --git a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts b/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts deleted file mode 100644 index b369ba4374b..00000000000 --- a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts +++ /dev/null @@ -1,88 +0,0 @@ -/// - -describe('getFormattingEditsForRange', function() { - // - // Verify that formatting the typescript file "sourceFileName" results in the - // baseline file "baselineFileName". - // - function getFormattingEditsForRange(sourceFileName: string) { - var baselineFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + "BaseLine.ts"; - sourceFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + ".ts"; - - var typescriptLS = new Harness.TypeScriptLS(); - typescriptLS.addDefaultLibrary(); - typescriptLS.addFile(sourceFileName); - - var ls = typescriptLS.getLanguageService(); - var script = ls.languageService.getScriptAST(sourceFileName); - assert.notNull(script); - - var edits = ls.languageService.getFormattingEditsForRange(sourceFileName, 0, script.limChar, new Services.FormatCodeOptions()); - typescriptLS.checkEdits(sourceFileName, baselineFileName, edits); - } - - describe('test cases for formatting engine', function() { - it("formats typescript constructs properly", function() { - getFormattingEditsForRange('typescriptConstructs'); - }); - it("formats document ready function properly", function() { - getFormattingEditsForRange('documentReadyFunction'); - }); - it("formats on closing bracket properly", function() { - getFormattingEditsForRange('onClosingBracket'); - }); - it("formats various javascript constructs", function() { - getFormattingEditsForRange('various'); - }); - it("formats main javascript program", function() { - getFormattingEditsForRange('main'); - }); - it("formats on semicolon properly", function() { - getFormattingEditsForRange('onSemiColon'); - }); - it("formats enum with trailling tab characters properly", function() { - getFormattingEditsForRange('tabAfterCloseCurly'); - }); - it("formats object literal", function() { - getFormattingEditsForRange('objectLiteral'); - }); - it("formats with statements", function() { - getFormattingEditsForRange('withStatement'); - }); - it("formats ':' and '?' in parameters", function() { - getFormattingEditsForRange('colonAndQMark'); - }); - it("formats 'import' declaration", function() { - getFormattingEditsForRange('importDeclaration'); - }); - it("formats exported class with implicit module", function() { - //TODO: this is to force generation of implicit module in AST - var svGenTarget = TypeScript.moduleGenTarget; - try { - TypeScript.moduleGenTarget = TypeScript.ModuleGenTarget.Asynchronous; - getFormattingEditsForRange('implicitModule'); - } - finally { - TypeScript.moduleGenTarget = svGenTarget; - } - }); - it("formats constructor statements correctelly", function() { - getFormattingEditsForRange('spaceAfterConstructor'); - }); - it("formats classes and interfaces correctelly", function() { - getFormattingEditsForRange('classes'); - }); - it("formats modules correctly", function() { - getFormattingEditsForRange('modules'); - }); - it("formats fat arrow expressions correctelly", function() { - getFormattingEditsForRange('fatArrowFunctions'); - }); - it("formats empty object/interface literals correctelly", function() { - getFormattingEditsForRange('emptyInterfaceLiteral'); - }); - it("formats variable declaration lists", function() { - getFormattingEditsForRange('formatVariableDeclarationList'); - }); - }); -}); diff --git a/src/harness/unittests/textChanges.ts b/src/harness/unittests/textChanges.ts index 8269b6de6be..3625b30a009 100644 --- a/src/harness/unittests/textChanges.ts +++ b/src/harness/unittests/textChanges.ts @@ -2,6 +2,9 @@ /// /// +// Some tests have trailing whitespace +// tslint:disable trim-trailing-whitespace + namespace ts { describe("textChanges", () => { function findChild(name: string, n: Node) { @@ -572,7 +575,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); - }) + }); } { const text = ` @@ -581,7 +584,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); - }) + }); } { const text = ` @@ -590,7 +593,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -599,7 +602,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -609,7 +612,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); - }) + }); } { const text = ` @@ -619,7 +622,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); - }) + }); } { const text = ` @@ -629,7 +632,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter16", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -639,7 +642,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter17", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -648,7 +651,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter18", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -656,7 +659,7 @@ class A { x; }`; runSingleFileTest("insertNodeAfterMultipleNodes", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - let newNodes = []; + const newNodes = []; for (let i = 0; i < 11 /*error doesn't occur with fewer nodes*/; ++i) { newNodes.push( createProperty(undefined, undefined, i + "", undefined, undefined, undefined)); @@ -714,7 +717,7 @@ class A { class A { x = foo } -` +`; runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createProperty( /*decorators*/ undefined, @@ -732,7 +735,7 @@ class A { x() { } } -` +`; runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createProperty( /*decorators*/ undefined, @@ -749,7 +752,7 @@ class A { interface A { x } -` +`; runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createProperty( /*decorators*/ undefined, @@ -766,7 +769,7 @@ interface A { interface A { x() } -` +`; runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createProperty( /*decorators*/ undefined, @@ -781,7 +784,7 @@ interface A { { const text = ` let x = foo -` +`; runSingleFileTest("insertNodeInStatementListAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createStatement(createParen(createLiteral(1))); changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), newNode, { suffix: newLineCharacter }); diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index e4da7a62763..9a04b723ac2 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,9 +5,7 @@ interface DOMTokenList { } interface NodeList { - - - /** + /** * Returns an array of key, value pairs for every entry in the list */ entries(): IterableIterator<[number, Node]>; @@ -17,23 +15,23 @@ interface NodeList { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; - /** + /** * Returns an list of keys in the list */ keys(): IterableIterator; - /** + /** * Returns an list of values in the list */ values(): IterableIterator; - - [Symbol.iterator](): IterableIterator + + [Symbol.iterator](): IterableIterator; } interface NodeListOf { - /** + /** * Returns an array of key, value pairs for every entry in the list */ entries(): IterableIterator<[number, TNode]>; @@ -44,14 +42,14 @@ interface NodeListOf { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; - /** + /** * Returns an list of keys in the list */ keys(): IterableIterator; - /** + /** * Returns an list of values in the list */ - values(): IterableIterator; - - [Symbol.iterator](): IterableIterator + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; } diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index 5b90333f1d5..b2255dab881 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -17,7 +17,7 @@ declare var Map: MapConstructor; interface ReadonlyMap { forEach(callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; - get(key: K): V|undefined; + get(key: K): V | undefined; has(key: K): boolean; readonly size: number; } diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 88f70758e5a..2e56221fe9a 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -268,7 +268,7 @@ interface Object { * Determines whether an object has a property with the specified name. * @param v A property name. */ - hasOwnProperty(v: PropertyKey): boolean + hasOwnProperty(v: PropertyKey): boolean; /** * Determines whether a specified property is enumerable. @@ -486,10 +486,10 @@ interface String { bold(): string; /** Returns a HTML element */ - fixed(): string + fixed(): string; /** Returns a HTML element and sets the color attribute value */ - fontcolor(color: string): string + fontcolor(color: string): string; /** Returns a HTML element and sets the size attribute value */ fontsize(size: number): string; diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index fe56c6e8bfb..73f0d45cda7 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -91,7 +91,7 @@ interface IArguments { } interface Map { - [Symbol.iterator](): IterableIterator<[K,V]>; + [Symbol.iterator](): IterableIterator<[K, V]>; entries(): IterableIterator<[K, V]>; keys(): IterableIterator; values(): IterableIterator; diff --git a/src/lib/es2015.proxy.d.ts b/src/lib/es2015.proxy.d.ts index efccfd47cc5..89f9ebf55c0 100644 --- a/src/lib/es2015.proxy.d.ts +++ b/src/lib/es2015.proxy.d.ts @@ -12,11 +12,11 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, argArray: any, newTarget?: any): object + construct? (target: T, argArray: any, newTarget?: any): object; } interface ProxyConstructor { revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; - new (target: T, handler: ProxyHandler): T + new (target: T, handler: ProxyHandler): T; } declare var Proxy: ProxyConstructor; diff --git a/src/lib/es2015.symbol.d.ts b/src/lib/es2015.symbol.d.ts index d7ea4fa0328..44a5f17d742 100644 --- a/src/lib/es2015.symbol.d.ts +++ b/src/lib/es2015.symbol.d.ts @@ -7,8 +7,8 @@ interface Symbol { } interface SymbolConstructor { - /** - * A reference to the prototype. + /** + * A reference to the prototype. */ readonly prototype: Symbol; @@ -16,17 +16,17 @@ interface SymbolConstructor { * Returns a new unique Symbol value. * @param description Description of the new Symbol object. */ - (description?: string|number): symbol; + (description?: string | number): symbol; /** - * Returns a Symbol object from the global symbol registry matching the given key if found. + * Returns a Symbol object from the global symbol registry matching the given key if found. * Otherwise, returns a new symbol with this key. * @param key key to search for. */ for(key: string): symbol; /** - * Returns a key from the global symbol registry matching the given Symbol if found. + * Returns a key from the global symbol registry matching the given Symbol if found. * Otherwise, returns a undefined. * @param sym Symbol to find the key for. */ diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 7177b78e483..71e4cb7c893 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -1,55 +1,55 @@ /// interface SymbolConstructor { - /** - * A method that determines if a constructor object recognizes an object as one of the - * constructor’s instances. Called by the semantics of the instanceof operator. + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. */ readonly hasInstance: symbol; - /** + /** * A Boolean value that if true indicates that an object should flatten to its array elements * by Array.prototype.concat. */ readonly isConcatSpreadable: symbol; /** - * A regular expression method that matches the regular expression against a string. Called - * by the String.prototype.match method. + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. */ readonly match: symbol; - /** - * A regular expression method that replaces matched substrings of a string. Called by the + /** + * A regular expression method that replaces matched substrings of a string. Called by the * String.prototype.replace method. */ readonly replace: symbol; /** - * A regular expression method that returns the index within a string that matches the + * A regular expression method that returns the index within a string that matches the * regular expression. Called by the String.prototype.search method. */ readonly search: symbol; - /** - * A function valued property that is the constructor function that is used to create + /** + * A function valued property that is the constructor function that is used to create * derived objects. */ readonly species: symbol; /** - * A regular expression method that splits a string at the indices that match the regular + * A regular expression method that splits a string at the indices that match the regular * expression. Called by the String.prototype.split method. */ readonly split: symbol; - /** + /** * A method that converts an object to a corresponding primitive value. * Called by the ToPrimitive abstract operation. */ readonly toPrimitive: symbol; - /** + /** * A String value that is used in the creation of the default string description of an object. * Called by the built-in method Object.prototype.toString. */ @@ -165,7 +165,7 @@ interface RegExp { * Replaces text in a string, using this regular expression. * @param string A String object or string literal whose contents matching against * this regular expression will be replaced - * @param replaceValue A String object or string literal containing the text to replace for every + * @param replaceValue A String object or string literal containing the text to replace for every * successful match of this regular expression. */ [Symbol.replace](string: string, replaceValue: string): string; @@ -241,10 +241,10 @@ interface String { } /** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; @@ -255,7 +255,7 @@ interface DataView { } /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Int8Array { @@ -263,7 +263,7 @@ interface Int8Array { } /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { @@ -271,7 +271,7 @@ interface Uint8Array { } /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { @@ -279,7 +279,7 @@ interface Uint8ClampedArray { } /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { @@ -287,7 +287,7 @@ interface Int16Array { } /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { @@ -295,7 +295,7 @@ interface Uint16Array { } /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { @@ -303,7 +303,7 @@ interface Int32Array { } /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { @@ -319,7 +319,7 @@ interface Float32Array { } /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { diff --git a/src/lib/es2017.sharedmemory.d.ts b/src/lib/es2017.sharedmemory.d.ts index 440b74ff016..d9f986627ca 100644 --- a/src/lib/es2017.sharedmemory.d.ts +++ b/src/lib/es2017.sharedmemory.d.ts @@ -13,8 +13,8 @@ interface SharedArrayBuffer { length: number; /** * Returns a section of an SharedArrayBuffer. - */ - slice(begin:number, end?:number): SharedArrayBuffer; + */ + slice(begin: number, end?: number): SharedArrayBuffer; readonly [Symbol.species]: SharedArrayBuffer; readonly [Symbol.toStringTag]: "SharedArrayBuffer"; } diff --git a/src/lib/es2017.string.d.ts b/src/lib/es2017.string.d.ts index 51f8e410ecf..3a440f887e9 100644 --- a/src/lib/es2017.string.d.ts +++ b/src/lib/es2017.string.d.ts @@ -1,27 +1,27 @@ -interface String { - /** - * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. - * The padding is applied from the start (left) of the current string. - * - * @param maxLength The length of the resulting string once the current string has been padded. - * If this parameter is smaller than the current string's length, the current string will be returned as it is. - * - * @param fillString The string to pad the current string with. - * If this string is too long, it will be truncated and the left-most part will be applied. - * The default value for this parameter is " " (U+0020). - */ - padStart(maxLength: number, fillString?: string): string; - - /** - * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. - * The padding is applied from the end (right) of the current string. - * - * @param maxLength The length of the resulting string once the current string has been padded. - * If this parameter is smaller than the current string's length, the current string will be returned as it is. - * - * @param fillString The string to pad the current string with. - * If this string is too long, it will be truncated and the left-most part will be applied. - * The default value for this parameter is " " (U+0020). - */ - padEnd(maxLength: number, fillString?: string): string; -} +interface String { + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the start (left) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ + padStart(maxLength: number, fillString?: string): string; + + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the end (right) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ + padEnd(maxLength: number, fillString?: string): string; +} diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 7d3a2179a38..97a1b6e74cb 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -2,6 +2,8 @@ /// ECMAScript APIs ///////////////////////////// +// tslint:disable no-var-keyword + declare const NaN: number; declare const Infinity: number; @@ -490,7 +492,7 @@ interface NumberConstructor { declare const Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { - readonly raw: ReadonlyArray + readonly raw: ReadonlyArray; } interface Math { @@ -1354,14 +1356,14 @@ type Readonly = { */ type Pick = { [P in K]: T[P]; -} +}; /** * Construct a type with a set of properties K of type T */ type Record = { [P in K]: T; -} +}; /** * Marker for contextual 'this' type @@ -1383,7 +1385,7 @@ interface ArrayBuffer { /** * Returns a section of an ArrayBuffer. */ - slice(begin:number, end?:number): ArrayBuffer; + slice(begin: number, end?: number): ArrayBuffer; } interface ArrayBufferConstructor { @@ -4169,7 +4171,7 @@ declare const Float64Array: Float64ArrayConstructor; /// ECMAScript Internationalization API ///////////////////////////// -declare module Intl { +declare namespace Intl { interface CollatorOptions { usage?: string; localeMatcher?: string; @@ -4197,7 +4199,7 @@ declare module Intl { new (locales?: string | string[], options?: CollatorOptions): Collator; (locales?: string | string[], options?: CollatorOptions): Collator; supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[]; - } + }; interface NumberFormatOptions { localeMatcher?: string; @@ -4234,7 +4236,7 @@ declare module Intl { new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[]; - } + }; interface DateTimeFormatOptions { localeMatcher?: string; @@ -4277,7 +4279,7 @@ declare module Intl { new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[]; - } + }; } interface String { diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index b163a7e5154..8f10c631ec7 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -29,7 +29,7 @@ interface TextStreamBase { /** * Closes a text stream. - * It is not necessary to close standard streams; they close automatically when the process ends. If + * It is not necessary to close standard streams; they close automatically when the process ends. If * you close a standard stream, be aware that any other pointers to that standard stream become invalid. */ Close(): void; diff --git a/src/lib/webworker.importscripts.d.ts b/src/lib/webworker.importscripts.d.ts index f48f75ee87a..1c4c4f4e953 100644 --- a/src/lib/webworker.importscripts.d.ts +++ b/src/lib/webworker.importscripts.d.ts @@ -1,6 +1,6 @@ ///////////////////////////// -/// WorkerGlobalScope APIs +/// WorkerGlobalScope APIs ///////////////////////////// -// These are only available in a Web Worker +// These are only available in a Web Worker declare function importScripts(...urls: string[]): void; diff --git a/src/server/builder.ts b/src/server/builder.ts index e056f0ae8c7..108c0a0c64b 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/server/client.ts b/src/server/client.ts index 8e81a423837..ce7cef12c11 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -33,7 +33,7 @@ namespace ts.server { } export class SessionClient implements LanguageService { - private sequence: number = 0; + private sequence = 0; private lineMaps: ts.Map = ts.createMap(); private messages: string[] = []; private lastRenameEntry: RenameEntry; diff --git a/src/server/server.ts b/src/server/server.ts index bfd4e422047..4e443add779 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -135,7 +135,7 @@ namespace ts.server { try { this.fd = fs.openSync(this.logFilename, "w"); } - catch(_) { + catch (_) { // swallow the error and keep logging disabled if file cannot be opened } } @@ -315,7 +315,7 @@ namespace ts.server { } const body: protocol.TypesInstallerInitializationFailedEventBody = { message: response.message - } + }; const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; this.eventSender.event(body, eventName); return; @@ -473,14 +473,14 @@ namespace ts.server { const cmdLineVerbosity = getLogLevel(findArgument("--logVerbosity")); const envLogOptions = parseLoggingEnvironmentString(process.env["TSS_LOG"]); - const logFileName = cmdLineLogFileName - ? stripQuotes(cmdLineLogFileName) + const logFileName = cmdLineLogFileName + ? stripQuotes(cmdLineLogFileName) : envLogOptions.logToFile ? envLogOptions.file || (__dirname + "/.log" + process.pid.toString()) : undefined; const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel; - return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity) + return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity); } // This places log file in the directory containing editorServices.js // TODO: check that this location is writable diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 74497504ba3..0a9d8ee29f4 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -24,7 +24,7 @@ namespace ts.server.typingsInstaller { try { fs.appendFileSync(this.logFile, text + sys.newLine); } - catch(e) { + catch (e) { this.logEnabled = false; } } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 743c13ccf38..0c1511ff1eb 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -301,7 +301,6 @@ namespace ts.codefix { } function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] { - //const newImportText = isDefault ? `default as ${name}` : name; const importList = importClause.namedBindings; const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name)); // case 1: @@ -556,7 +555,7 @@ namespace ts.codefix { } function createChangeTracker() { - return textChanges.ChangeTracker.fromCodeFixContext(context);; + return textChanges.ChangeTracker.fromCodeFixContext(context); } function createCodeAction( diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 725b9b99506..4f60f7ed160 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -36,11 +36,11 @@ namespace ts.FindAllReferences { } else if (node.kind === SyntaxKind.ObjectLiteralExpression) { entry.kind = ScriptElementKind.interfaceElement; - entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)] + entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)]; } else if (node.kind === SyntaxKind.ClassExpression) { entry.kind = ScriptElementKind.localClassElement; - entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)] + entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)]; } else { entry.kind = getNodeKind(node); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 6f8a67a0535..424399db72e 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -57,7 +57,7 @@ namespace ts.textChanges { * ^ - pos for the next variable declaration will point here * const y; // this is y * ^ - end for previous variable declaration - * Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding + * Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding * variable declaration and trailing trivia for 'y' should include (whitespace, comment 'this is y', newline). * By default when removing nodes we adjust start and end positions to respect specification of the trivia above. * If pos\end should be interpreted literally 'useNonAdjustedStartPosition' or 'useNonAdjustedEndPosition' should be set to true @@ -265,7 +265,7 @@ namespace ts.textChanges { options: {}, range: { pos: after.end, end: after.end }, node: createToken(SyntaxKind.SemicolonToken) - }) + }); } } const endPosition = getAdjustedEndPosition(sourceFile, after, options); @@ -275,7 +275,7 @@ namespace ts.textChanges { /** * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, - * i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that + * i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that * for them separators are treated as the part of the node. */ public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { @@ -307,8 +307,8 @@ namespace ts.textChanges { // c, // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') // a,* - //***insertedtext# - //###b, + // ***insertedtext# + // ###b, // c, // find line and character of the next element const lineAndCharOfNextElement = getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); @@ -317,7 +317,7 @@ namespace ts.textChanges { let prefix: string; let startPos: number; if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { - // next element is located on the same line with separator: + // next element is located on the same line with separator: // a,$$$$b // ^ ^ // | |-next element @@ -393,7 +393,7 @@ namespace ts.textChanges { // insert element before the line break on the line that contains 'after' element let insertPos = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false); if (insertPos !== end && isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { - insertPos-- + insertPos--; } this.changes.push({ sourceFile, diff --git a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt index 46782aaa1d6..ed6ee0dcd87 100644 --- a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt +++ b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt @@ -1,4 +1,4 @@ -lib.d.ts(32,18): error TS2300: Duplicate identifier 'eval'. +lib.d.ts(34,18): error TS2300: Duplicate identifier 'eval'. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS2300: Duplicate identifier 'eval'. diff --git a/tslint.json b/tslint.json index 5e72aedf065..920f6087909 100644 --- a/tslint.json +++ b/tslint.json @@ -1,4 +1,5 @@ { + "rulesDirectory": "built/local/tslint", "rules": { "no-bom": true, "class-name": true, @@ -49,5 +50,5 @@ "object-literal-surrounding-space": true, "no-type-assertion-whitespace": true, "no-in-operator": true - } + } } From 6234cbb82f18cb7d8634f33dfd8c37139c7d0e2e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 17 Mar 2017 14:04:36 -0700 Subject: [PATCH 161/167] Move comment to JSDoc --- src/compiler/parser.ts | 3 --- src/compiler/types.ts | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f5c4d880072..5d585e2658a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5643,9 +5643,6 @@ namespace ts { } function parseImportEqualsDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray, identifier: ts.Identifier): ImportEqualsDeclaration { - // ImportEquals declaration of type: - // import x = require("mod"); or - // import x = M.x; const importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7728c2b8519..a7adf28ac8e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1838,6 +1838,11 @@ namespace ts { export type ModuleReference = EntityName | ExternalModuleReference; + /** + * One of: + * - import x = require("mod"); + * - import x = M.x; + */ export interface ImportEqualsDeclaration extends DeclarationStatement { kind: SyntaxKind.ImportEqualsDeclaration; parent?: SourceFile | ModuleBlock; From a710e9433b28c0c9b692ad6244415777ec3d565d Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 17 Mar 2017 17:20:43 -0700 Subject: [PATCH 162/167] Do not report semantic diagnostics for infered and external projects with only .js files --- .../unittests/tsserverProjectSystem.ts | 36 +++++++++++++++++++ src/server/session.ts | 9 +---- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index a13835fa7f3..5ea0df91caa 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3006,6 +3006,42 @@ namespace ts.projectSystem { const errorResult = session.executeCommand(dTsFileGetErrRequest).response; assert.isTrue(errorResult.length === 0); }); + + it("should be turned on for js-only external projects with skipLibCheck=false", () => { + const jsFile = { + path: "/a/b/file1.js", + content: "let x =1;" + }; + const dTsFile = { + path: "/a/b/file2.d.ts", + content: ` + interface T { + name: string; + }; + interface T { + name: number; + };` + }; + const host = createServerHost([jsFile, dTsFile]); + const session = createSession(host); + + const openExternalProjectRequest = makeSessionRequest( + CommandNames.OpenExternalProject, + { + projectFileName: "project1", + rootFiles: toExternalFiles([jsFile.path, dTsFile.path]), + options: { skipLibCheck: false } + } + ); + session.executeCommand(openExternalProjectRequest); + + const dTsFileGetErrRequest = makeSessionRequest( + CommandNames.SemanticDiagnosticsSync, + { file: dTsFile.path } + ); + const errorResult = session.executeCommand(dTsFileGetErrRequest).response; + assert.isTrue(errorResult.length === 0); + }); }); describe("non-existing directories listed in config file input array", () => { diff --git a/src/server/session.ts b/src/server/session.ts index f82d11ba91b..8dd0411d077 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -26,14 +26,7 @@ namespace ts.server { } function shouldSkipSematicCheck(project: Project) { - if (project.getCompilerOptions().skipLibCheck !== undefined) { - return false; - } - - if ((project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject()) { - return true; - } - return false; + return (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject(); } interface FileStart { From cc6140f6e92280096de0a9b8964e9b865ad9b573 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 17 Mar 2017 17:22:02 -0700 Subject: [PATCH 163/167] Only emit "use strict" when users ask for or the file is external module --- src/compiler/transformers/module/module.ts | 3 ++- src/compiler/transformers/module/system.ts | 3 ++- tests/baselines/reference/importHelpersInIsolatedModules.js | 1 - tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js | 1 - tests/baselines/reference/isolatedModulesPlainFile-System.js | 1 - .../transpile/Does not generate semantic diagnostics.js | 1 - .../transpile/Generates expected syntactic diagnostics.js | 1 - .../Generates no diagnostics for missing file references.js | 1 - .../transpile/Generates no diagnostics with valid inputs.js | 1 - ... error when compiler-options module-kind is out-of-range.js | 1 - ...rror when compiler-options target-script is out-of-range.js | 1 - tests/baselines/reference/transpile/Sets module name.js | 1 - .../reference/transpile/Support options with lib values.js | 1 - .../reference/transpile/Support options with types values.js | 1 - .../reference/transpile/Supports backslashes in file name.js | 1 - .../baselines/reference/transpile/Supports setting allowJs.js | 1 - .../transpile/Supports setting allowSyntheticDefaultImports.js | 1 - .../transpile/Supports setting allowUnreachableCode.js | 1 - .../reference/transpile/Supports setting allowUnusedLabels.js | 1 - .../baselines/reference/transpile/Supports setting baseUrl.js | 1 - .../baselines/reference/transpile/Supports setting charset.js | 1 - .../reference/transpile/Supports setting declaration.js | 1 - .../reference/transpile/Supports setting declarationDir.js | 1 - .../baselines/reference/transpile/Supports setting emitBOM.js | 1 - .../transpile/Supports setting emitDecoratorMetadata.js | 1 - .../transpile/Supports setting experimentalDecorators.js | 1 - .../Supports setting forceConsistentCasingInFileNames.js | 1 - .../reference/transpile/Supports setting isolatedModules.js | 1 - tests/baselines/reference/transpile/Supports setting jsx.js | 1 - .../reference/transpile/Supports setting jsxFactory.js | 1 - tests/baselines/reference/transpile/Supports setting lib.js | 1 - tests/baselines/reference/transpile/Supports setting locale.js | 1 - tests/baselines/reference/transpile/Supports setting module.js | 1 - .../reference/transpile/Supports setting moduleResolution.js | 1 - .../baselines/reference/transpile/Supports setting newLine.js | 1 - tests/baselines/reference/transpile/Supports setting noEmit.js | 1 - .../reference/transpile/Supports setting noEmitHelpers.js | 1 - .../reference/transpile/Supports setting noEmitOnError.js | 1 - .../reference/transpile/Supports setting noErrorTruncation.js | 1 - .../transpile/Supports setting noFallthroughCasesInSwitch.js | 1 - .../reference/transpile/Supports setting noImplicitAny.js | 1 - .../reference/transpile/Supports setting noImplicitReturns.js | 1 - .../reference/transpile/Supports setting noImplicitThis.js | 1 - tests/baselines/reference/transpile/Supports setting noLib.js | 1 - .../reference/transpile/Supports setting noResolve.js | 1 - tests/baselines/reference/transpile/Supports setting out.js | 1 - tests/baselines/reference/transpile/Supports setting outDir.js | 1 - .../baselines/reference/transpile/Supports setting outFile.js | 1 - tests/baselines/reference/transpile/Supports setting paths.js | 1 - .../reference/transpile/Supports setting preserveConstEnums.js | 1 - .../reference/transpile/Supports setting reactNamespace.js | 1 - .../reference/transpile/Supports setting removeComments.js | 1 - .../baselines/reference/transpile/Supports setting rootDir.js | 1 - .../baselines/reference/transpile/Supports setting rootDirs.js | 1 - .../transpile/Supports setting skipDefaultLibCheck.js | 1 - .../reference/transpile/Supports setting skipLibCheck.js | 1 - .../reference/transpile/Supports setting strictNullChecks.js | 1 - .../reference/transpile/Supports setting stripInternal.js | 1 - .../transpile/Supports setting suppressExcessPropertyErrors.js | 1 - .../Supports setting suppressImplicitAnyIndexErrors.js | 1 - .../reference/transpile/Supports setting typeRoots.js | 1 - tests/baselines/reference/transpile/Supports setting types.js | 1 - .../reference/transpile/Supports urls in file name.js | 1 - .../reference/transpile/Uses correct newLine character.js | 1 - tests/baselines/reference/transpile/transpile .js files.js | 1 - .../transpile/transpile file as tsx if jsx is specified.js | 1 - 66 files changed, 4 insertions(+), 66 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 80a8c985c56..4ef9c674ad9 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -89,7 +89,8 @@ namespace ts { startLexicalEnvironment(); const statements: Statement[] = []; - const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + const ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile)); + const statementOffset = addPrologueDirectives(statements, node.statements, ensureUseStrict, sourceElementVisitor); if (shouldEmitUnderscoreUnderscoreESModule()) { append(statements, createUnderscoreUnderscoreESModule()); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 1a362c47fd1..642ac1ce6fb 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -225,7 +225,8 @@ namespace ts { startLexicalEnvironment(); // Add any prologue directives. - const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + const ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile)); + const statementOffset = addPrologueDirectives(statements, node.statements, ensureUseStrict, sourceElementVisitor); // var __moduleName = context_1 && context_1.id; statements.push( diff --git a/tests/baselines/reference/importHelpersInIsolatedModules.js b/tests/baselines/reference/importHelpersInIsolatedModules.js index 454fde430d3..26a9cafa188 100644 --- a/tests/baselines/reference/importHelpersInIsolatedModules.js +++ b/tests/baselines/reference/importHelpersInIsolatedModules.js @@ -68,7 +68,6 @@ C = tslib_1.__decorate([ dec ], C); //// [script.js] -"use strict"; var tslib_1 = require("tslib"); var A = (function () { function A() { diff --git a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js index f40d2173685..7026a7d9bed 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js @@ -5,5 +5,4 @@ run(1); //// [isolatedModulesPlainFile-CommonJS.js] -"use strict"; run(1); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-System.js b/tests/baselines/reference/isolatedModulesPlainFile-System.js index 39b648e071a..43cad51d213 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-System.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-System.js @@ -6,7 +6,6 @@ run(1); //// [isolatedModulesPlainFile-System.js] System.register([], function (exports_1, context_1) { - "use strict"; var __moduleName = context_1 && context_1.id; return { setters: [], diff --git a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js index 61a703e13bb..eb8be3556a1 100644 --- a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js +++ b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js @@ -1,3 +1,2 @@ -"use strict"; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js index 9d108d63313..c2c5134015c 100644 --- a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js +++ b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js @@ -1,4 +1,3 @@ -"use strict"; a; b; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js index 88d98628eee..9324d64de1e 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js @@ -1,4 +1,3 @@ -"use strict"; /// var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js index 61a703e13bb..eb8be3556a1 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js @@ -1,3 +1,2 @@ -"use strict"; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js index 1ceb1bcd146..c7570e81192 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js @@ -1,2 +1 @@ -"use strict"; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js index 1ceb1bcd146..c7570e81192 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js @@ -1,2 +1 @@ -"use strict"; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Sets module name.js b/tests/baselines/reference/transpile/Sets module name.js index dfe9605fc9e..72164ed6b16 100644 --- a/tests/baselines/reference/transpile/Sets module name.js +++ b/tests/baselines/reference/transpile/Sets module name.js @@ -1,5 +1,4 @@ System.register("NamedModule", [], function (exports_1, context_1) { - "use strict"; var __moduleName = context_1 && context_1.id; var x; return { diff --git a/tests/baselines/reference/transpile/Support options with lib values.js b/tests/baselines/reference/transpile/Support options with lib values.js index 36c68f08b9f..1c5faaae678 100644 --- a/tests/baselines/reference/transpile/Support options with lib values.js +++ b/tests/baselines/reference/transpile/Support options with lib values.js @@ -1,3 +1,2 @@ -"use strict"; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with types values.js b/tests/baselines/reference/transpile/Support options with types values.js index 36c68f08b9f..1c5faaae678 100644 --- a/tests/baselines/reference/transpile/Support options with types values.js +++ b/tests/baselines/reference/transpile/Support options with types values.js @@ -1,3 +1,2 @@ -"use strict"; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports backslashes in file name.js b/tests/baselines/reference/transpile/Supports backslashes in file name.js index 942449753b0..7e5b546deba 100644 --- a/tests/baselines/reference/transpile/Supports backslashes in file name.js +++ b/tests/baselines/reference/transpile/Supports backslashes in file name.js @@ -1,3 +1,2 @@ -"use strict"; var x; //# sourceMappingURL=b.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowJs.js b/tests/baselines/reference/transpile/Supports setting allowJs.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting allowJs.js +++ b/tests/baselines/reference/transpile/Supports setting allowJs.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js +++ b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting baseUrl.js b/tests/baselines/reference/transpile/Supports setting baseUrl.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting baseUrl.js +++ b/tests/baselines/reference/transpile/Supports setting baseUrl.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting charset.js b/tests/baselines/reference/transpile/Supports setting charset.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting charset.js +++ b/tests/baselines/reference/transpile/Supports setting charset.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declaration.js b/tests/baselines/reference/transpile/Supports setting declaration.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting declaration.js +++ b/tests/baselines/reference/transpile/Supports setting declaration.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declarationDir.js b/tests/baselines/reference/transpile/Supports setting declarationDir.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting declarationDir.js +++ b/tests/baselines/reference/transpile/Supports setting declarationDir.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitBOM.js b/tests/baselines/reference/transpile/Supports setting emitBOM.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting emitBOM.js +++ b/tests/baselines/reference/transpile/Supports setting emitBOM.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js +++ b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js +++ b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js +++ b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting isolatedModules.js b/tests/baselines/reference/transpile/Supports setting isolatedModules.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting isolatedModules.js +++ b/tests/baselines/reference/transpile/Supports setting isolatedModules.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsx.js b/tests/baselines/reference/transpile/Supports setting jsx.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting jsx.js +++ b/tests/baselines/reference/transpile/Supports setting jsx.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsxFactory.js b/tests/baselines/reference/transpile/Supports setting jsxFactory.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting jsxFactory.js +++ b/tests/baselines/reference/transpile/Supports setting jsxFactory.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting lib.js b/tests/baselines/reference/transpile/Supports setting lib.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting lib.js +++ b/tests/baselines/reference/transpile/Supports setting lib.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting locale.js b/tests/baselines/reference/transpile/Supports setting locale.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting locale.js +++ b/tests/baselines/reference/transpile/Supports setting locale.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting module.js b/tests/baselines/reference/transpile/Supports setting module.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting module.js +++ b/tests/baselines/reference/transpile/Supports setting module.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting moduleResolution.js b/tests/baselines/reference/transpile/Supports setting moduleResolution.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting moduleResolution.js +++ b/tests/baselines/reference/transpile/Supports setting moduleResolution.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting newLine.js b/tests/baselines/reference/transpile/Supports setting newLine.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting newLine.js +++ b/tests/baselines/reference/transpile/Supports setting newLine.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmit.js b/tests/baselines/reference/transpile/Supports setting noEmit.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmit.js +++ b/tests/baselines/reference/transpile/Supports setting noEmit.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js +++ b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js +++ b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noLib.js b/tests/baselines/reference/transpile/Supports setting noLib.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noLib.js +++ b/tests/baselines/reference/transpile/Supports setting noLib.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noResolve.js b/tests/baselines/reference/transpile/Supports setting noResolve.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noResolve.js +++ b/tests/baselines/reference/transpile/Supports setting noResolve.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting out.js b/tests/baselines/reference/transpile/Supports setting out.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting out.js +++ b/tests/baselines/reference/transpile/Supports setting out.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outDir.js b/tests/baselines/reference/transpile/Supports setting outDir.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting outDir.js +++ b/tests/baselines/reference/transpile/Supports setting outDir.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outFile.js b/tests/baselines/reference/transpile/Supports setting outFile.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting outFile.js +++ b/tests/baselines/reference/transpile/Supports setting outFile.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting paths.js b/tests/baselines/reference/transpile/Supports setting paths.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting paths.js +++ b/tests/baselines/reference/transpile/Supports setting paths.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js +++ b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting reactNamespace.js b/tests/baselines/reference/transpile/Supports setting reactNamespace.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting reactNamespace.js +++ b/tests/baselines/reference/transpile/Supports setting reactNamespace.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting removeComments.js b/tests/baselines/reference/transpile/Supports setting removeComments.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting removeComments.js +++ b/tests/baselines/reference/transpile/Supports setting removeComments.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDir.js b/tests/baselines/reference/transpile/Supports setting rootDir.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDir.js +++ b/tests/baselines/reference/transpile/Supports setting rootDir.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDirs.js b/tests/baselines/reference/transpile/Supports setting rootDirs.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDirs.js +++ b/tests/baselines/reference/transpile/Supports setting rootDirs.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js +++ b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting stripInternal.js b/tests/baselines/reference/transpile/Supports setting stripInternal.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting stripInternal.js +++ b/tests/baselines/reference/transpile/Supports setting stripInternal.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting typeRoots.js b/tests/baselines/reference/transpile/Supports setting typeRoots.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting typeRoots.js +++ b/tests/baselines/reference/transpile/Supports setting typeRoots.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting types.js b/tests/baselines/reference/transpile/Supports setting types.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting types.js +++ b/tests/baselines/reference/transpile/Supports setting types.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports urls in file name.js b/tests/baselines/reference/transpile/Supports urls in file name.js index 3923d3c9a41..50fa840c62e 100644 --- a/tests/baselines/reference/transpile/Supports urls in file name.js +++ b/tests/baselines/reference/transpile/Supports urls in file name.js @@ -1,3 +1,2 @@ -"use strict"; var x; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Uses correct newLine character.js b/tests/baselines/reference/transpile/Uses correct newLine character.js index bab9c3c4443..976498c2da8 100644 --- a/tests/baselines/reference/transpile/Uses correct newLine character.js +++ b/tests/baselines/reference/transpile/Uses correct newLine character.js @@ -1,3 +1,2 @@ -"use strict"; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile .js files.js b/tests/baselines/reference/transpile/transpile .js files.js index c17099d84ba..36551461def 100644 --- a/tests/baselines/reference/transpile/transpile .js files.js +++ b/tests/baselines/reference/transpile/transpile .js files.js @@ -1,3 +1,2 @@ -"use strict"; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js index baa27ee64ce..8620309214f 100644 --- a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js +++ b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js @@ -1,3 +1,2 @@ -"use strict"; var x = React.createElement("div", null); //# sourceMappingURL=file.js.map \ No newline at end of file From 50c18bbea07b0ec169c417e9aa002c2caf97adcc Mon Sep 17 00:00:00 2001 From: andy-ms Date: Sun, 19 Mar 2017 09:57:14 -0700 Subject: [PATCH 164/167] Fix typo --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a7adf28ac8e..363187e9cf3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2226,7 +2226,7 @@ namespace ts { endOfFileToken: Token; fileName: string; - /* internal */ path: Path; + /* @internal */ path: Path; text: string; amdDependencies: AmdDependency[]; From 2a2c1a9c1445cfea3f3767b3e7ecb8cc2b701be2 Mon Sep 17 00:00:00 2001 From: andy-ms Date: Sun, 19 Mar 2017 10:02:00 -0700 Subject: [PATCH 165/167] Add comment --- src/compiler/sys.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 3f585900654..5275d210172 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -202,7 +202,7 @@ namespace ts { if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, // flip all byte pairs and treat as little endian. - len &= ~1; + len &= ~1; // Round down to a multiple of 2 for (let i = 0; i < len; i += 2) { const temp = buffer[i]; buffer[i] = buffer[i + 1]; From 76ffba60fb101f49b2ac7c719d53da58320b10ab Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 20 Mar 2017 09:07:04 -0700 Subject: [PATCH 166/167] Fix `gulp runtests-browser` --- Gulpfile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index e025ce6eaa8..738ec107862 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -749,7 +749,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo const originalMap = file.sourceMap; const prebundledContent = file.contents.toString(); // Make paths absolute to help sorcery deal with all the terrible paths being thrown around - originalMap.sources = originalMap.sources.map(s => path.resolve(s)); + originalMap.sources = originalMap.sources.map(s => path.resolve(path.join("src/harness", s))); // intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap originalMap.file = "built/local/_stream_0.js"; From 0152e8c4bb0b700d551c7d04a7413470bae44217 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 20 Mar 2017 08:42:27 -0700 Subject: [PATCH 167/167] Fix lint scripts --- Gulpfile.ts | 39 ++------ Jakefile.js | 49 +++-------- src/harness/fourslash.ts | 2 +- .../formatting/getFormattingEditsForRange.ts | 88 +++++++++++++++++++ src/lib/es5.d.ts | 2 - ...ariableDeclarationInStrictMode1.errors.txt | 2 +- 6 files changed, 109 insertions(+), 73 deletions(-) create mode 100644 src/harness/unittests/services/formatting/getFormattingEditsForRange.ts diff --git a/Gulpfile.ts b/Gulpfile.ts index e025ce6eaa8..cc506c44ee9 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -2,6 +2,7 @@ import * as cp from "child_process"; import * as path from "path"; import * as fs from "fs"; +import child_process = require("child_process"); import originalGulp = require("gulp"); import helpMaker = require("gulp-help"); import runSequence = require("run-sequence"); @@ -1019,40 +1020,16 @@ function spawnLintWorker(files: {path: string}[], callback: (failures: number) = } gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => { - const fileMatcher = RegExp(cmdLineOptions["files"]); if (fold.isTravis()) console.log(fold.start("lint")); - - let files: {stat: fs.Stats, path: string}[] = []; - return gulp.src(lintTargets, { read: false }) - .pipe(through2.obj((chunk, enc, cb) => { - files.push(chunk); - cb(); - }, (cb) => { - files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size); - const workerCount = cmdLineOptions["workers"]; - for (let i = 0; i < workerCount; i++) { - spawnLintWorker(files, finished); - } - - let completed = 0; - let failures = 0; - function finished(fails) { - completed++; - failures += fails; - if (completed === workerCount) { - if (fold.isTravis()) console.log(fold.end("lint")); - if (failures > 0) { - throw new Error(`Linter errors: ${failures}`); - } - else { - cb(); - } - } - } - })); + const fileMatcher = cmdLineOptions["files"]; + const files = fileMatcher + ? `src/**/${fileMatcher}` + : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/harness/unittests/services/**/*.ts'"; + const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; + console.log("Linting: " + cmd); + child_process.execSync(cmd, { stdio: [0, 1, 2] }); }); - gulp.task("default", "Runs 'local'", ["local"]); gulp.task("watch", "Watches the src/ directory for changes and executes runtests-parallel.", [], () => { diff --git a/Jakefile.js b/Jakefile.js index 2b0f0fe1f42..9c2b3d38d10 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1177,43 +1177,16 @@ function spawnLintWorker(files, callback) { } desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex"); -task("lint", ["build-rules"], function () { +task("lint", ["build-rules"], () => { if (fold.isTravis()) console.log(fold.start("lint")); - var startTime = mark(); - var failed = 0; - var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || ""); - var done = {}; - for (var i in lintTargets) { - var target = lintTargets[i]; - if (!done[target] && fileMatcher.test(target)) { - done[target] = fs.statSync(target).size; - } - } - - var workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length; - - var names = Object.keys(done).sort(function (namea, nameb) { - return done[namea] - done[nameb]; + const fileMatcher = process.env.f || process.env.file || process.env.files; + const files = fileMatcher + ? `src/**/${fileMatcher}` + : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/harness/unittests/services/**/*.ts'"; + const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; + console.log("Linting: " + cmd); + jake.exec([cmd], { interactive: true }, () => { + if (fold.isTravis()) console.log(fold.end("lint")); + complete(); }); - - for (var i = 0; i < workerCount; i++) { - spawnLintWorker(names, finished); - } - - var completed = 0; - var failures = 0; - function finished(fails) { - completed++; - failures += fails; - if (completed === workerCount) { - measure(startTime); - if (fold.isTravis()) console.log(fold.end("lint")); - if (failures > 0) { - fail('Linter errors.', failed); - } - else { - complete(); - } - } - } -}, { async: true }); +}); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 092c84996f1..98ebacd49b1 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -931,7 +931,7 @@ namespace FourSlash { const { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined }; const result: ts.ReferenceEntry = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess: !!isWriteAccess, isDefinition: !!isDefinition }; if (isInString !== undefined) { - result.isInString = isInString + result.isInString = isInString; } return result; } diff --git a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts b/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts new file mode 100644 index 00000000000..9ad1102d2f4 --- /dev/null +++ b/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts @@ -0,0 +1,88 @@ +/// + +describe('getFormattingEditsForRange', function() { + // + // Verify that formatting the typescript file "sourceFileName" results in the + // baseline file "baselineFileName". + // + function getFormattingEditsForRange(sourceFileName: string) { + var baselineFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + "BaseLine.ts"; + sourceFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + ".ts"; + + var typescriptLS = new Harness.TypeScriptLS(); + typescriptLS.addDefaultLibrary(); + typescriptLS.addFile(sourceFileName); + + var ls = typescriptLS.getLanguageService(); + var script = ls.languageService.getScriptAST(sourceFileName); + assert.notNull(script); + + var edits = ls.languageService.getFormattingEditsForRange(sourceFileName, 0, script.limChar, new Services.FormatCodeOptions()); + typescriptLS.checkEdits(sourceFileName, baselineFileName, edits); + } + + describe('test cases for formatting engine', function() { + it("formats typescript constructs properly", function() { + getFormattingEditsForRange('typescriptConstructs'); + }); + it("formats document ready function properly", function() { + getFormattingEditsForRange('documentReadyFunction'); + }); + it("formats on closing bracket properly", function() { + getFormattingEditsForRange('onClosingBracket'); + }); + it("formats various javascript constructs", function() { + getFormattingEditsForRange('various'); + }); + it("formats main javascript program", function() { + getFormattingEditsForRange('main'); + }); + it("formats on semicolon properly", function() { + getFormattingEditsForRange('onSemiColon'); + }); + it("formats enum with trailling tab characters properly", function() { + getFormattingEditsForRange('tabAfterCloseCurly'); + }); + it("formats object literal", function() { + getFormattingEditsForRange('objectLiteral'); + }); + it("formats with statements", function() { + getFormattingEditsForRange('withStatement'); + }); + it("formats ':' and '?' in parameters", function() { + getFormattingEditsForRange('colonAndQMark'); + }); + it("formats 'import' declaration", function() { + getFormattingEditsForRange('importDeclaration'); + }); + it("formats exported class with implicit module", function() { + //TODO: this is to force generation of implicit module in AST + var svGenTarget = TypeScript.moduleGenTarget; + try { + TypeScript.moduleGenTarget = TypeScript.ModuleGenTarget.Asynchronous; + getFormattingEditsForRange('implicitModule'); + } + finally { + TypeScript.moduleGenTarget = svGenTarget; + } + }); + it("formats constructor statements correctelly", function() { + getFormattingEditsForRange('spaceAfterConstructor'); + }); + it("formats classes and interfaces correctelly", function() { + getFormattingEditsForRange('classes'); + }); + it("formats modules correctly", function() { + getFormattingEditsForRange('modules'); + }); + it("formats fat arrow expressions correctelly", function() { + getFormattingEditsForRange('fatArrowFunctions'); + }); + it("formats empty object/interface literals correctelly", function() { + getFormattingEditsForRange('emptyInterfaceLiteral'); + }); + it("formats variable declaration lists", function() { + getFormattingEditsForRange('formatVariableDeclarationList'); + }); + }); +}); diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 97a1b6e74cb..b92d335457a 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -2,8 +2,6 @@ /// ECMAScript APIs ///////////////////////////// -// tslint:disable no-var-keyword - declare const NaN: number; declare const Infinity: number; diff --git a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt index ed6ee0dcd87..46782aaa1d6 100644 --- a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt +++ b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt @@ -1,4 +1,4 @@ -lib.d.ts(34,18): error TS2300: Duplicate identifier 'eval'. +lib.d.ts(32,18): error TS2300: Duplicate identifier 'eval'. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS2300: Duplicate identifier 'eval'.